第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

在配置xml文件時(shí)出現(xiàn)的問(wèn)題

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [beans-b.xml]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/springframework/context/index/CandidateComponentsIndexLoader

這個(gè)是在單元測(cè)試的時(shí)候出現(xiàn)的錯(cuò)誤,好像顯示的是無(wú)法找到spring framework中的某個(gè)類,但是我在配置的過(guò)程中dataSource是沒(méi)問(wèn)題的,

錯(cuò)誤應(yīng)該是出在EntityManagerFactory裏,但是那段代碼我是直接複製過(guò)來(lái)的,包掃描的包名也被我改了,所以出了什麼錯(cuò)誤請(qǐng)大家指正

正在回答

2 回答

import?org.junit.After;
import?org.junit.Before;
import?org.junit.Test;
import?org.springframework.context.ApplicationContext;
import?org.springframework.context.support.ClassPathXmlApplicationContext;

public?class?SpringDataTest?{
????/**
?????*?檢測(cè)連接石的正確性
?????*/
????private?ApplicationContext?ctx;
????@Before
????public?void?Setup(){
????????System.out.println("setup!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
????????ctx?=?new?ClassPathXmlApplicationContext("beans-b.xml");
????????System.out.println("setup!!!");

????}
????@After
????public?void?tearDown(){
????????ctx?=?null;
????}
????@Test
????public?void?testEntityManagementFactory(){

????}
}

這個(gè)是測(cè)試代碼

0 回復(fù) 有任何疑惑可以回復(fù)我~
<?xml?version="1.0"?encoding="UTF-8"?>
<beans?xmlns="http://www.springframework.org/schema/beans"
???????xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
???????xmlns:context="http://www.springframework.org/schema/context"
???????xmlns:tx="http://www.springframework.org/schema/tx"
???????xmlns:jpa="http://www.springframework.org/schema/data/jpa"
???????xsi:schemaLocation="http://www.springframework.org/schema/beans?http://www.springframework.org/schema/beans/spring-beans.xsd
??????http://www.springframework.org/schema/data/jpa?http://www.springframework.org/schema/data/jpa/spring-jpa-1.3.xsd
??????http://www.springframework.org/schema/tx?http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
??????http://www.springframework.org/schema/context?http://www.springframework.org/schema/context/spring-context-4.0.xsd">
????<!-->jdbc?連接<!-->
????????<bean?id="dataSource"?class="org.springframework.jdbc.datasource.DriverManagerDataSource">
????????????<property?name="driverClassName"?value="com.mysql.jdbc.Driver"/>
????????????<property?name="url"?value="jdbc:mysql:///test"/>
????????????<property?name="username"?value="root"/>
????????</bean>
????<!--2?配置EntityManagerFactory-->
????<bean?id="entityManagerFactory"?class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
????????<property?name="dataSource"?ref="dataSource"/>
????????<property?name="jpaVendorAdapter">
????????????<bean?class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"/>
????????</property>
????????<property?name="packagesToScan"?value="com.example"/>

????????<property?name="jpaProperties">
????????????<props>
????????????????<prop?key="hibernate.ejb.naming_strategy">org.hibernate.cfg.ImprovedNamingStrategy</prop>
????????????????<prop?key="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</prop>
????????????????<prop?key="hibernate.show_sql">true</prop>
????????????????<prop?key="hibernate.format_sql">true</prop>
????????????????<prop?key="hibernate.hbm2ddl.auto">update</prop>
????????????</props>
????????</property>

????</bean>



????<!-->jpa?連接<!-->



</beans>

這是我的xml文件

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

在配置xml文件時(shí)出現(xiàn)的問(wèn)題

我要回答 關(guān)注問(wèn)題
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)