SpringMVC + hiberante 整合报错,跪求神人指导。。。

问题描述

问题找了一天了,还望神人多多指点启动就报错,先贴上配置信息Pom.xml<projectxmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0http://maven.apache.org/maven-v4_0_0.xsd"><modelVersion>4.0.0</modelVersion><groupId>com.chinide</groupId><artifactId>appServer</artifactId><packaging>war</packaging><version>0.0.1-SNAPSHOT</version><name>appServerMavenWebapp</name><url>http://maven.apache.org</url><dependencies><dependency><groupId>org.springframework</groupId><artifactId>spring-core</artifactId><version>4.1.5.RELEASE</version></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-context</artifactId><version>4.1.5.RELEASE</version></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-tx</artifactId><version>4.1.5.RELEASE</version></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-hibernate</artifactId><version>1.2.9</version></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-orm</artifactId><version>4.1.5.RELEASE</version></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-webmvc</artifactId><version>4.1.5.RELEASE</version></dependency><!--hibernate--><dependency><groupId>org.hibernate</groupId><artifactId>hibernate-core</artifactId><version>4.3.8.Final</version></dependency><dependency><groupId>org.hibernate</groupId><artifactId>hibernate-entitymanager</artifactId><version>4.3.8.Final</version></dependency><dependency><groupId>org.hibernate</groupId><artifactId>hibernate-ehcache</artifactId><version>4.3.8.Final</version></dependency><!--end--><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><version>5.1.34</version></dependency><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>4.12</version><scope>test</scope></dependency><dependency><groupId>com.alibaba</groupId><artifactId>druid</artifactId><version>1.0.13</version></dependency><!--jstl--><dependency><groupId>javax.servlet</groupId><artifactId>jstl</artifactId><version>1.2</version></dependency><dependency><groupId>javax.servlet</groupId><artifactId>servlet-api</artifactId><version>3.0-alpha-1</version><scope>provided</scope></dependency><dependency><groupId>javax.servlet.jsp</groupId><artifactId>jsp-api</artifactId><version>2.2.1-b03</version><scope>provided</scope></dependency><!--log4j--><dependency><groupId>log4j</groupId><artifactId>log4j</artifactId><version>1.2.17</version></dependency><!--文件上传--><dependency><groupId>commons-fileupload</groupId><artifactId>commons-fileupload</artifactId><version>1.2.2</version></dependency><!--fastJsonjson数组有关的--><dependency><groupId>com.alibaba</groupId><artifactId>fastjson</artifactId><version>1.1.26</version></dependency><!--aspectjweaver.jar这是SpringAOP所要用到的包--><dependency><groupId>org.aspectj</groupId><artifactId>aspectjweaver</artifactId><version>1.7.1</version></dependency><!--使用Jackson把Java对象转换成JSON字串--><dependency><groupId>org.codehaus.jackson</groupId><artifactId>jackson-mapper-asl</artifactId><version>1.9.11</version></dependency><dependency><groupId>net.sf.json-lib</groupId><artifactId>json-lib</artifactId><version>2.4</version><classifier>jdk15</classifier></dependency><dependency><groupId>commons-codec</groupId><artifactId>commons-codec</artifactId><version>20041127.091804</version></dependency></dependencies><build><finalName>appServer</finalName></build></project>

Spring.xml<?xmlversion="1.0"encoding="UTF-8"?><beansxmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:context="http://www.springframework.org/schema/context"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-4.1.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-4.1.xsd"><context:annotation-config/><!--引入属性文件--><context:property-placeholderlocation="classpath:config/config.properties"/><!--自动扫描dao和service包(自动注入)--><context:component-scanbase-package="com.chinide.dao.impl,com.chinide.service.impl"/></beans>

Spring-mvc.xml<?xmlversion="1.0"encoding="UTF-8"?><beansxmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:p="http://www.springframework.org/schema/p"xmlns:context="http://www.springframework.org/schema/context"xmlns:mvc="http://www.springframework.org/schema/mvc"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-3.2.xsdhttp://www.springframework.org/schema/mvchttp://www.springframework.org/schema/mvc/spring-mvc-3.2.xsdhttp://www.springframework.org/schema/aophttp://www.springframework.org/schema/aop/spring-aop-3.2.xsdhttp://www.springframework.org/schema/txhttp://www.springframework.org/schema/tx/spring-tx-3.2.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-3.2.xsd"><!--注解扫描包--><context:component-scanbase-package="com.chinide.controller"/><!--开启mvc注解--><mvc:annotation-driven/><mvc:interceptors><mvc:interceptor><mvc:mappingpath="/**"/><mvc:exclude-mappingpath="/download/**"/><mvc:exclude-mappingpath="/uploads/**"/><mvc:exclude-mappingpath="/upfiles/**"/><mvc:exclude-mappingpath="/pay/**"/><mvc:exclude-mappingpath="/app/**"/><beanclass="com.chinide.common.interceptor.UserInterceptor"/></mvc:interceptor><mvc:interceptor><mvc:mappingpath="/**"/><beanclass="com.chinide.common.interceptor.AppInterceptor"/></mvc:interceptor></mvc:interceptors><!--<beanid="viewResolver"class="org.springframework.web.servlet.view.InternalResourceViewResolver"><propertyname="prefix"value="/"></property><propertyname="suffix"value=".jsp"></property></bean>--></beans>

解决方案

解决方案二:
Spring-hibernate.xml<?xmlversion="1.0"encoding="UTF-8"?><beansxmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:tx="http://www.springframework.org/schema/tx"xmlns:aop="http://www.springframework.org/schema/aop"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-4.1.xsdhttp://www.springframework.org/schema/txhttp://www.springframework.org/schema/tx/spring-tx-4.1.xsdhttp://www.springframework.org/schema/aophttp://www.springframework.org/schema/aop/spring-aop-4.1.xsd"><!--JNDI(通过Tomcat)方式配置数据源--><!--<beanid="dataSource"class="org.springframework.jndi.JndiObjectFactoryBean"><propertyname="jndiName"value="${jndiName}"></property></bean>--><!--配置数据源--><beanname="dataSource"class="com.alibaba.druid.pool.DruidDataSource"init-method="init"destroy-method="close"><propertyname="url"value="${jdbc_url}"/><propertyname="username"value="${jdbc_username}"/><propertyname="password"value="${jdbc_password}"/><!--初始化连接大小--><propertyname="initialSize"value="1"/><!--连接池最大使用连接数量--><propertyname="maxActive"value="20"/><!--连接池最大空闲--><!--<propertyname="maxIdle"value="1"/>--><!--连接池最小空闲--><!--<propertyname="minIdle"value="1"/>--><!--获取连接最大等待时间--><propertyname="maxWait"value="60000"/><!--<propertyname="poolPreparedStatements"value="true"/><propertyname="maxPoolPreparedStatementPerConnectionSize"value="33"/>--><propertyname="validationQuery"value="${validationQuery}"/><propertyname="testOnBorrow"value="false"/><propertyname="testOnReturn"value="false"/><propertyname="testWhileIdle"value="true"/><!--配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒--><propertyname="timeBetweenEvictionRunsMillis"value="60000"/><!--配置一个连接在池中最小生存的时间,单位是毫秒--><propertyname="minEvictableIdleTimeMillis"value="25200000"/><!--打开removeAbandoned功能--><propertyname="removeAbandoned"value="true"/><!--1800秒,也就是30分钟--><propertyname="removeAbandonedTimeout"value="1800"/><!--关闭abanded连接时输出错误日志--><propertyname="logAbandoned"value="true"/><!--监控数据库--><!--<propertyname="filters"value="stat"/>--><propertyname="filters"value="mergeStat"/></bean><beanid="jdbcTemplate"class="org.springframework.jdbc.core.JdbcTemplate"><propertyname="dataSource"><refbean="dataSource"/></property></bean><!--配置hibernatesession工厂--><beanid="sessionFactory"class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"><propertyname="dataSource"ref="dataSource"/><propertyname="hibernateProperties"><props><propkey="hibernate.hbm2ddl.auto">update</prop><propkey="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop><propkey="hibernate.show_sql">true</prop><propkey="hibernate.format_sql">true</prop></props></property><!--自动扫描注解方式配置的hibernate类文件--><propertyname="packagesToScan"><list><value>com.chinide.model</value></list></property></bean><!--配置事务管理器--><beanid="transactionManagerBeanName"class="org.springframework.orm.hibernate4.HibernateTransactionManager"><propertyname="sessionFactory"ref="sessionFactory"></property></bean><!--注解方式配置事物--><tx:annotation-driventransaction-manager="transactionManagerBeanName"/><!--拦截器方式配置事物--><!--<tx:adviceid="transactionAdvice"transaction-manager="transactionManager"><tx:attributes><tx:methodname="add*"propagation="REQUIRED"/><tx:methodname="save*"propagation="REQUIRED"/><tx:methodname="update*"propagation="REQUIRED"/><tx:methodname="modify*"propagation="REQUIRED"/><tx:methodname="edit*"propagation="REQUIRED"/><tx:methodname="delete*"propagation="REQUIRED"/><tx:methodname="remove*"propagation="REQUIRED"/><tx:methodname="repair"propagation="REQUIRED"/><tx:methodname="deleteAndRepair"propagation="REQUIRED"/><tx:methodname="get*"propagation="SUPPORTS"read-only="true"/><tx:methodname="find*"propagation="SUPPORTS"read-only="true"/><tx:methodname="load*"propagation="SUPPORTS"read-only="true"/><tx:methodname="search*"propagation="SUPPORTS"read-only="true"/><tx:methodname="datagrid*"propagation="SUPPORTS"read-only="true"/><tx:methodname="*"propagation="SUPPORTS"/></tx:attributes></tx:advice><aop:config><aop:pointcutid="transactionPointcut"expression="execution(*com.chinide.service.*.*(..))"/><aop:advisorpointcut-ref="transactionPointcut"advice-ref="transactionAdvice"/></aop:config>--></beans>

web.xml<?xmlversion="1.0"encoding="UTF-8"?><web-appversion="3.0"xmlns="http://java.sun.com/xml/ns/javaee"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://java.sun.com/xml/ns/javaeehttp://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"><display-name></display-name><context-param><param-name>log4jConfigLocation</param-name><param-value>classpath:config/log4j.properties</param-value></context-param><context-param><param-name>contextConfigLocation</param-name><param-value>classpath:config/spring.xml,classpath:config/spring-hibernate.xml,</param-value></context-param><!--配置log4j.xml监听器--><listener><listener-class>org.springframework.web.util.Log4jConfigListener</listener-class></listener><listener><listener-class>org.springframework.web.context.ContextLoaderListener</listener-class></listener><filter><filter-name>encodingFilter</filter-name><filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class><init-param><param-name>encoding</param-name><param-value>UTF-8</param-value></init-param></filter><filter-mapping><filter-name>encodingFilter</filter-name><url-pattern>/*</url-pattern></filter-mapping><!--Hibernate的session丢失解决方法--><filter><filter-name>openSessionInView</filter-name><filter-class>org.springframework.orm.hibernate4.support.OpenSessionInViewFilter</filter-class><init-param><param-name>sessionFactoryBeanName</param-name><param-value>sessionFactory</param-value></init-param><init-param><param-name>singleSession</param-name><param-value>true</param-value></init-param><init-param><param-name>flushMode</param-name><param-value>AUTO</param-value></init-param></filter><filter-mapping><filter-name>openSessionInView</filter-name><url-pattern>/*</url-pattern></filter-mapping><!--springMVC配置--><servlet><description>springmvcservlet</description><servlet-name>springMVC</servlet-name><servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class><init-param><description>springmvc配置文件</description><param-name>contextConfigLocation</param-name><param-value>classpath:config/spring-mvc.xml</param-value></init-param><load-on-startup>1</load-on-startup></servlet><servlet-mapping><servlet-name>springMVC</servlet-name><url-pattern>/*</url-pattern></servlet-mapping><welcome-file-list><welcome-file>index.jsp</welcome-file></welcome-file-list></web-app>

解决方案三:
报错信息如下org.springframework.beans.factory.BeanCreationException:Errorcreatingbeanwithname'org.springframework.transaction.interceptor.TransactionInterceptor#0':Errorsettingpropertyvalues;nestedexceptionisorg.springframework.beans.NotWritablePropertyException:Invalidproperty'transactionManagerBeanName'ofbeanclass[org.springframework.transaction.interceptor.TransactionInterceptor]:Beanproperty'transactionManagerBeanName'isnotwritableorhasaninvalidsettermethod.Doestheparametertypeofthesettermatchthereturntypeofthegetter?atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1506)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)atorg.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)atorg.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)atorg.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)atorg.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)atorg.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:755)atorg.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)atorg.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)atorg.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)atorg.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)atorg.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)atorg.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4973)atorg.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5467)atorg.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)atorg.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)atorg.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)atjava.util.concurrent.FutureTask.run(UnknownSource)atjava.util.concurrent.ThreadPoolExecutor.runWorker(UnknownSource)atjava.util.concurrent.ThreadPoolExecutor$Worker.run(UnknownSource)atjava.lang.Thread.run(UnknownSource)Causedby:org.springframework.beans.NotWritablePropertyException:Invalidproperty'transactionManagerBeanName'ofbeanclass[org.springframework.transaction.interceptor.TransactionInterceptor]:Beanproperty'transactionManagerBeanName'isnotwritableorhasaninvalidsettermethod.Doestheparametertypeofthesettermatchthereturntypeofthegetter?atorg.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:1076)atorg.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:927)atorg.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:95)atorg.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:75)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1502)

解决方案四:
沙发?莫非我是默认大神?
解决方案五:
。。。。怎么每人回复呢?自顶
解决方案六:
你的错误日志下面应该还有吧没贴全
解决方案七:
transactionManagerBeanName这个m,没有get和set方法,你把set方法加上
解决方案八:
transactionManagerBeanName在TransactionInterceptor类里没有正确注入,可以用ref的方式指向,一般不会报错。

时间: 2024-09-25 21:09:25

SpringMVC + hiberante 整合报错,跪求神人指导。。。的相关文章

odi安装报错 ~~~跪求~~

问题描述 odi安装报错 ~~~跪求~~ 在安装fmw_12.2.1.0.0_odi.jar时候报这个问题,我用的是1.8 的jdk 而且是在jdk的bin目录下执行的 求解答

急!was忘记控制台密码,修改security后,kill掉dmgr,重启报错,求大侠指导

问题描述 急!was忘记控制台密码,修改security后,kill掉dmgr,重启报错,求大侠指导 10C was忘记控制台密码,看网上说把security.xml中ture改为false然后kill掉dmgr再启动时报错,请各位大侠赐教,谢谢!!! 另外SystemOut.log中有一句[1/15/16 16:11:03:327 CST] 00000000 WsServerImpl E WSVR0100W: An error occurred initializing dmgr [class

Spring3+Struts2+Hibernate4+Mybatis整合报错,求大神解救!!!

问题描述 [org.springframework.web.context.ContextLoader]Contextinitializationfailedorg.springframework.beans.factory.BeanCreationException:Errorcreatingbeanwithname'org.mybatis.spring.mapper.MapperScannerConfigurer#0'definedinclasspathresource[applicatio

SSH整合报错,求大神指导!!

问题描述 2014-10-1114:51:21org.apache.catalina.startup.HostConfigdeployDirectory信息:DeployingwebapplicationdirectoryROOT2014-10-1114:51:21org.apache.catalina.startup.HostConfigdeployDirectory信息:DeployingwebapplicationdirectorySSHTest12014-10-1114:51:22,42

maven 整合springmvc spring myatis整合报错

问题描述 maven 整合springmvc spring myatis整合报错 java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].StandardContext[]] at java.util.concurrent.FutureTask.

springMVC配置报错,求大神帮忙

问题描述 springMVC配置报错,求大神帮忙 解决方案 解决方案二: 解决方案三: 解决方案四: 解决方案五: No mapping found for HTTP request with URI [/demo/index.html] in DispatcherServlet with name 'spring' 说的很明白了 解决方案六: 建立也demo文件夹,把index.html挪进去. 解决方案七: RequestMapping("/demo/*")试试

spring+springmvc+mybatis 报错。求大神指教。

问题描述 spring+springmvc+mybatis 报错.求大神指教. 严重: StandardWrapper.Throwableorg.springframework.beans.factory.BeanCreationException: Error creating bean with name 'index': Injection of autowired dependencies failed; nested exception is org.springframework.b

SpringMVC+mybatis运行报错

问题描述 SpringMVC+mybatis运行报错 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [spring-mybatis.xml]: Invocation of init method failed; nested exception is org.sprin

spring mvc与struts 整合报错

问题描述 spring mvc与struts 整合报错 报错如下求帮忙,谢谢严重: Exception starting filter struts2Unable to load configuration. - action - file:/E:/java/eclipse/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/bishe/WEB-INF/classes/struts.xml:11:74 at org.apa