笔记72 高级SSM整合

遇到的问题:

1.进行spring mvc测试的时候报错

测试代码:

 1 package com.li.test;
 2 
 3 import com.github.pagehelper.PageInfo;
 4 import com.li.dao.DepartmentMapper;
 5 import com.li.dao.EmployeeMapper;
 6 import com.li.pojo.Employee;
 7 import org.junit.Before;
 8 import org.junit.Test;
 9 import org.junit.runner.RunWith;
10 import org.springframework.beans.factory.annotation.Autowired;
11 import org.springframework.mock.web.MockHttpServletRequest;
12 import org.springframework.test.context.ContextConfiguration;
13 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
14 import org.springframework.test.context.web.WebAppConfiguration;
15 import org.springframework.test.web.servlet.MockMvc;
16 import org.springframework.test.web.servlet.MvcResult;
17 import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
18 import org.springframework.test.web.servlet.setup.MockMvcBuilders;
19 import org.springframework.web.context.WebApplicationContext;
20 
21 import java.util.List;
22 
23 /**
24  * 测试CRUD请求
25  */
26 
27 /**
28  * 报错java.lang.NoClassDefFoundError: javax/servlet/SessionCookieConfig
29  * 需要servlet3.0支持
30  */
31 @RunWith(SpringJUnit4ClassRunner.class)
32 @WebAppConfiguration
33 @ContextConfiguration(locations = {"classpath:applicationContext.xml","classpath:springMVC.xml"})
34 public class MVCTest {
35 
36     //传入Spring mvc的IOC
37     @Autowired
38     WebApplicationContext context;
39 
40     //虚拟的mvc请求
41     MockMvc mockMvc;
42 
43     @Before
44     public void initMockMvc(){
45        mockMvc=MockMvcBuilders.webAppContextSetup(context).build();
46     }
47 
48     @Test
49     public void testPage() throws Exception{
50        MvcResult mvcResult=mockMvc.perform(MockMvcRequestBuilders.get("/emps").param("start","1")).andReturn();
51        MockHttpServletRequest request=mvcResult.getRequest();
52        PageInfo pageInfo=(PageInfo) request.getAttribute("pageInfo");
53        System.out.println("当前页码:"+pageInfo.getPageNum());
54         System.out.println("总页码:"+pageInfo.getPages());
55         System.out.println("总记录数:"+pageInfo.getTotal());
56         System.out.println("在页面需要连续显示的页码:");
57         int [] nums=pageInfo.getNavigatepageNums();
58         for (int i:nums){
59             System.out.println(" "+i);
60         }
61 
62         //获取员工数据
63         List<Employee> employeeList=pageInfo.getList();
64         for(Employee employee:employeeList){
65             System.out.println("ID:"+employee.getEmpId());
66         }
67     }
68 
69 }

报错:

  1 七月 26, 2018 9:31:46 下午 org.springframework.web.context.support.GenericWebApplicationContext prepareRefresh
  2 信息: Refreshing org.springframework.web.context.support.GenericWebApplicationContext@26be92ad: startup date [Thu Jul 26 21:31:46 CST 2018]; root of context hierarchy
  3 七月 26, 2018 9:31:47 下午 com.alibaba.druid.pool.DruidDataSource info
  4 信息: {dataSource-1} inited
  5 七月 26, 2018 9:31:47 下午 org.springframework.web.context.support.GenericWebApplicationContext refresh
  6 警告: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'departmentServiceImpl': Unsatisfied dependency expressed through field 'departmentMapper'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'departmentMapper' defined in file [E:\Java_练习\HSSMDEMO\target\classes\com\li\dao\DepartmentMapper.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSession' defined in class path resource [applicationContext.xml]: Cannot create inner bean 'com.github.pagehelper.PageInterceptor#70a9f84e' of type [com.github.pagehelper.PageInterceptor] while setting bean property 'plugins' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.github.pagehelper.PageInterceptor#70a9f84e' defined in class path resource [applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
  7 PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'properties' threw exception; nested exception is com.github.pagehelper.PageException: 初始化 helper [mysql  ]时出错:mysql  
  8 七月 26, 2018 9:31:47 下午 com.alibaba.druid.pool.DruidDataSource info
  9 信息: {dataSource-1} closed
 10 七月 26, 2018 9:31:47 下午 org.springframework.test.context.TestContextManager prepareTestInstance
 11 严重: Caught exception while allowing TestExecutionListener [org.springframework.test.context.web.ServletTestExecutionListener@67b6d4ae] to prepare test instance [com.li.test.MVCTest@45d2ade3]
 12 java.lang.IllegalStateException: Failed to load ApplicationContext
 13     at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:124)
 14     at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:83)
 15     at org.springframework.test.context.web.ServletTestExecutionListener.setUpRequestContextIfNecessary(ServletTestExecutionListener.java:189)
 16     at org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(ServletTestExecutionListener.java:131)
 17     at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:230)
 18     at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:228)
 19     at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:287)
 20     at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
 21     at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:289)
 22     at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:247)
 23     at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94)
 24     at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
 25     at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
 26     at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
 27     at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
 28     at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
 29     at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
 30     at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
 31     at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
 32     at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)
 33     at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
 34     at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
 35     at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
 36     at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
 37     at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
 38 Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'departmentServiceImpl': Unsatisfied dependency expressed through field 'departmentMapper'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'departmentMapper' defined in file [E:\Java_练习\HSSMDEMO\target\classes\com\li\dao\DepartmentMapper.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSession' defined in class path resource [applicationContext.xml]: Cannot create inner bean 'com.github.pagehelper.PageInterceptor#70a9f84e' of type [com.github.pagehelper.PageInterceptor] while setting bean property 'plugins' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.github.pagehelper.PageInterceptor#70a9f84e' defined in class path resource [applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
 39 PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'properties' threw exception; nested exception is com.github.pagehelper.PageException: 初始化 helper [mysql  ]时出错:mysql  
 40     at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:588)
 41     at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
 42     at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:366)
 43     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1264)
 44     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
 45     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
 46     at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
 47     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
 48     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
 49     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
 50     at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761)
 51     at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866)
 52     at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542)
 53     at org.springframework.test.context.web.AbstractGenericWebContextLoader.loadContext(AbstractGenericWebContextLoader.java:134)
 54     at org.springframework.test.context.web.AbstractGenericWebContextLoader.loadContext(AbstractGenericWebContextLoader.java:61)
 55     at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.delegateLoading(AbstractDelegatingSmartContextLoader.java:108)
 56     at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.loadContext(AbstractDelegatingSmartContextLoader.java:251)
 57     at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:98)
 58     at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:116)
 59     ... 24 more
 60 Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'departmentMapper' defined in file [E:\Java_练习\HSSMDEMO\target\classes\com\li\dao\DepartmentMapper.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSession' defined in class path resource [applicationContext.xml]: Cannot create inner bean 'com.github.pagehelper.PageInterceptor#70a9f84e' of type [com.github.pagehelper.PageInterceptor] while setting bean property 'plugins' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.github.pagehelper.PageInterceptor#70a9f84e' defined in class path resource [applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
 61 PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'properties' threw exception; nested exception is com.github.pagehelper.PageException: 初始化 helper [mysql  ]时出错:mysql  
 62     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireByType(AbstractAutowireCapableBeanFactory.java:1357)
 63     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1249)
 64     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
 65     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
 66     at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
 67     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
 68     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
 69     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
 70     at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208)
 71     at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138)
 72     at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066)
 73     at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:585)
 74     ... 42 more
 75 Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSession' defined in class path resource [applicationContext.xml]: Cannot create inner bean 'com.github.pagehelper.PageInterceptor#70a9f84e' of type [com.github.pagehelper.PageInterceptor] while setting bean property 'plugins' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.github.pagehelper.PageInterceptor#70a9f84e' defined in class path resource [applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
 76 PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'properties' threw exception; nested exception is com.github.pagehelper.PageException: 初始化 helper [mysql  ]时出错:mysql  
 77     at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:313)
 78     at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:122)
 79     at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedArray(BeanDefinitionValueResolver.java:370)
 80     at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:153)
 81     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1531)
 82     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1276)
 83     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
 84     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
 85     at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
 86     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
 87     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
 88     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
 89     at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208)
 90     at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138)
 91     at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066)
 92     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireByType(AbstractAutowireCapableBeanFactory.java:1342)
 93     ... 53 more
 94 Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.github.pagehelper.PageInterceptor#70a9f84e' defined in class path resource [applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
 95 PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'properties' threw exception; nested exception is com.github.pagehelper.PageException: 初始化 helper [mysql  ]时出错:mysql  
 96     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1568)
 97     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1276)
 98     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
 99     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
100     at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:299)
101     ... 68 more
102 Caused by: org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
103 PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'properties' threw exception; nested exception is com.github.pagehelper.PageException: 初始化 helper [mysql  ]时出错:mysql  
104     at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:121)
105     at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:75)
106     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1564)
107     ... 72 more
108 
109 
110 java.lang.IllegalStateException: Failed to load ApplicationContext
111 
112     at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:124)
113     at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:83)
114     at org.springframework.test.context.web.ServletTestExecutionListener.setUpRequestContextIfNecessary(ServletTestExecutionListener.java:189)
115     at org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(ServletTestExecutionListener.java:131)
116     at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:230)
117     at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:228)
118     at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:287)
119     at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
120     at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:289)
121     at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:247)
122     at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94)
123     at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
124     at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
125     at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
126     at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
127     at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
128     at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
129     at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
130     at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
131     at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)
132     at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
133     at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
134     at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
135     at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
136     at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
137 Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'departmentServiceImpl': Unsatisfied dependency expressed through field 'departmentMapper'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'departmentMapper' defined in file [E:\Java_练习\HSSMDEMO\target\classes\com\li\dao\DepartmentMapper.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSession' defined in class path resource [applicationContext.xml]: Cannot create inner bean 'com.github.pagehelper.PageInterceptor#70a9f84e' of type [com.github.pagehelper.PageInterceptor] while setting bean property 'plugins' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.github.pagehelper.PageInterceptor#70a9f84e' defined in class path resource [applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
138 PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'properties' threw exception; nested exception is com.github.pagehelper.PageException: 初始化 helper [mysql  ]时出错:mysql  
139     at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:588)
140     at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
141     at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:366)
142     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1264)
143     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
144     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
145     at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
146     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
147     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
148     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
149     at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761)
150     at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866)
151     at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542)
152     at org.springframework.test.context.web.AbstractGenericWebContextLoader.loadContext(AbstractGenericWebContextLoader.java:134)
153     at org.springframework.test.context.web.AbstractGenericWebContextLoader.loadContext(AbstractGenericWebContextLoader.java:61)
154     at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.delegateLoading(AbstractDelegatingSmartContextLoader.java:108)
155     at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.loadContext(AbstractDelegatingSmartContextLoader.java:251)
156     at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:98)
157     at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:116)
158     ... 24 more
159 Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'departmentMapper' defined in file [E:\Java_练习\HSSMDEMO\target\classes\com\li\dao\DepartmentMapper.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSession' defined in class path resource [applicationContext.xml]: Cannot create inner bean 'com.github.pagehelper.PageInterceptor#70a9f84e' of type [com.github.pagehelper.PageInterceptor] while setting bean property 'plugins' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.github.pagehelper.PageInterceptor#70a9f84e' defined in class path resource [applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
160 PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'properties' threw exception; nested exception is com.github.pagehelper.PageException: 初始化 helper [mysql  ]时出错:mysql  
161     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireByType(AbstractAutowireCapableBeanFactory.java:1357)
162     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1249)
163     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
164     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
165     at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
166     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
167     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
168     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
169     at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208)
170     at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138)
171     at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066)
172     at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:585)
173     ... 42 more
174 Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSession' defined in class path resource [applicationContext.xml]: Cannot create inner bean 'com.github.pagehelper.PageInterceptor#70a9f84e' of type [com.github.pagehelper.PageInterceptor] while setting bean property 'plugins' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.github.pagehelper.PageInterceptor#70a9f84e' defined in class path resource [applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
175 PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'properties' threw exception; nested exception is com.github.pagehelper.PageException: 初始化 helper [mysql  ]时出错:mysql  
176     at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:313)
177     at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:122)
178     at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedArray(BeanDefinitionValueResolver.java:370)
179     at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:153)
180     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1531)
181     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1276)
182     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
183     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
184     at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
185     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
186     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
187     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
188     at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208)
189     at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138)
190     at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066)
191     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireByType(AbstractAutowireCapableBeanFactory.java:1342)
192     ... 53 more
193 Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.github.pagehelper.PageInterceptor#70a9f84e' defined in class path resource [applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
194 PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'properties' threw exception; nested exception is com.github.pagehelper.PageException: 初始化 helper [mysql  ]时出错:mysql  
195     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1568)
196     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1276)
197     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
198     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
199     at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:299)
200     ... 68 more
201 Caused by: org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
202 PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'properties' threw exception; nested exception is com.github.pagehelper.PageException: 初始化 helper [mysql  ]时出错:mysql  
203     at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:121)
204     at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:75)
205     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1564)
206     ... 72 more
207 
208 
209 Process finished with exit code -1

原因:

@WebAppConfiguration默认扫描的是maven项目中的src/main/webapp中的配置文件,因为把所有的配置文件都放在src/main/resources中,所以才会报错,
需要重新指定配置文件:
@WebAppConfiguration(value = "src/main/resources")

2.使用IDEA配置完SSM后,整体的配置结构图:

3.IDEA配置tomcat

4.当Spring的IOC容器无法加载bean时,实在找不到错误就重新部署一下项目,有可能是某些jar包没有上传到服务器。

5.mybatis逆向工程

6.jQuery ajax

7.深入理解PageHelper

 

posted @ 2018-07-26 21:59  雨落忧伤-  阅读(387)  评论(0编辑  收藏  举报