Failed to load ApplicationContext
来源:2-7 验证Dao
顾寒久
2020-05-18
五月 18, 2020 10:45:10 上午 org.springframework.test.context.support.DefaultTestContextBootstrapper getDefaultTestExecutionListenerClassNames
信息: Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener]
五月 18, 2020 10:45:10 上午 org.springframework.test.context.support.DefaultTestContextBootstrapper getTestExecutionListeners
信息: Using TestExecutionListeners: [org.springframework.test.context.web.ServletTestExecutionListener@2c6a3f77, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener@246ae04d, org.springframework.test.context.support.DependencyInjectionTestExecutionListener@62043840, org.springframework.test.context.support.DirtiesContextTestExecutionListener@5315b42e, org.springframework.test.context.transaction.TransactionalTestExecutionListener@2ef9b8bc, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener@5d624da6]
五月 18, 2020 10:45:10 上午 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
信息: Loading XML bean definitions from class path resource [spring/spring-dao.xml]
五月 18, 2020 10:45:10 上午 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
信息: Loading XML bean definitions from class path resource [spring/spring-service.xml]
五月 18, 2020 10:45:11 上午 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
信息: Loading XML bean definitions from class path resource [spring/spring-redis.xml]
五月 18, 2020 10:45:11 上午 org.springframework.context.support.GenericApplicationContext prepareRefresh
信息: Refreshing org.springframework.context.support.GenericApplicationContext@9629756: startup date [Mon May 18 10:45:11 GMT+08:00 2020]; root of context hierarchy
10:45:11.257 [main] DEBUG org.apache.ibatis.logging.LogFactory - Logging initialized using ‘class org.apache.ibatis.logging.slf4j.Slf4jImpl’ adapter.
10:45:11.280 [main] DEBUG org.mybatis.spring.mapper.ClassPathMapperScanner - Creating MapperFactoryBean with name ‘areaDao’ and ‘com.lunwen.o2o.dao.AreaDao’ mapperInterface
10:45:11.280 [main] DEBUG org.mybatis.spring.mapper.ClassPathMapperScanner - Creating MapperFactoryBean with name ‘headLineDao’ and ‘com.lunwen.o2o.dao.HeadLineDao’ mapperInterface
10:45:11.280 [main] DEBUG org.mybatis.spring.mapper.ClassPathMapperScanner - Creating MapperFactoryBean with name ‘localAuthDao’ and ‘com.lunwen.o2o.dao.LocalAuthDao’ mapperInterface
10:45:11.280 [main] DEBUG org.mybatis.spring.mapper.ClassPathMapperScanner - Creating MapperFactoryBean with name ‘personInfoDao’ and ‘com.lunwen.o2o.dao.PersonInfoDao’ mapperInterface
10:45:11.280 [main] DEBUG org.mybatis.spring.mapper.ClassPathMapperScanner - Creating MapperFactoryBean with name ‘productCategoryDao’ and ‘com.lunwen.o2o.dao.ProductCategoryDao’ mapperInterface
10:45:11.280 [main] DEBUG org.mybatis.spring.mapper.ClassPathMapperScanner - Creating MapperFactoryBean with name ‘productDao’ and ‘com.lunwen.o2o.dao.ProductDao’ mapperInterface
10:45:11.280 [main] DEBUG org.mybatis.spring.mapper.ClassPathMapperScanner - Creating MapperFactoryBean with name ‘productImgDao’ and ‘com.lunwen.o2o.dao.ProductImgDao’ mapperInterface
10:45:11.280 [main] DEBUG org.mybatis.spring.mapper.ClassPathMapperScanner - Creating MapperFactoryBean with name ‘shopCategoryDao’ and ‘com.lunwen.o2o.dao.ShopCategoryDao’ mapperInterface
10:45:11.280 [main] DEBUG org.mybatis.spring.mapper.ClassPathMapperScanner - Creating MapperFactoryBean with name ‘shopDao’ and ‘com.lunwen.o2o.dao.ShopDao’ mapperInterface
10:45:11.280 [main] DEBUG org.mybatis.spring.mapper.ClassPathMapperScanner - Creating MapperFactoryBean with name ‘wechatAuthDao’ and ‘com.lunwen.o2o.dao.WechatAuthDao’ mapperInterface
五月 18, 2020 10:45:11 上午 org.springframework.context.support.GenericApplicationContext refresh
警告: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.lunwen.o2o.util.EncryptPropertyPlaceholderConfigurer] for bean with name ‘com.lunwen.o2o.util.EncryptPropertyPlaceholderConfigurer#0’ defined in class path resource [spring/spring-dao.xml]; nested exception is java.lang.ClassNotFoundException: com.lunwen.o2o.util.EncryptPropertyPlaceholderConfigurer
五月 18, 2020 10:45:11 上午 org.springframework.test.context.TestContextManager prepareTestInstance
严重: Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener@62043840] to prepare test instance [com.lunwen.o2o.dao.AreaDaoTest@5e0e82ae]
java.lang.IllegalStateException: Failed to load ApplicationContext
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:124)
at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:83)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:117)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:83)
at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:230)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:228)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:287)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:289)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:247)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunnerKaTeX parse error: Expected 'EOF', got '#' at position 1237: …olderConfigurer#̲0' defined in c…AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at org.springframework.util.ClassUtils.forName(ClassUtils.java:250)
at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:401)
at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1432)
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1377)
… 38 more
1回答
-
同学好,建议在没有解决问题的能力之前,不要直接复制粘贴最终源码的配置,而是跟着视频来一步步进行,因为有的类是后面才添加进去的,你配置文件用的最终源码的会由于缺少这些类而报错,这里由于配置文件用的Cannot find class [com.lunwen.o2o.util.EncryptPropertyPlaceholderConfigurer] 这个类,这里没有,才报了这个错误。还是跟着视频来,不然得不偿失。
012020-05-19
相似问题