springmvc+mybatis启动tomcat报错

YafengLiang 2016-12-26 06:19:47
18:15:48,736 INFO DispatcherServlet:489 - FrameworkServlet 'sm': initialization started
18:15:48,802 INFO XmlWebApplicationContext:582 - Refreshing WebApplicationContext for namespace 'sm-servlet': startup date [Mon Dec 26 18:15:48 CST 2016]; root of context hierarchy
18:15:48,916 INFO XmlBeanDefinitionReader:317 - Loading XML bean definitions from class path resource [applicationContext.xml]
18:15:49,599 INFO PropertySourcesPlaceholderConfigurer:172 - Loading properties file from class path resource [db.properties]
18:15:49,718 WARN XmlWebApplicationContext:550 - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'filters' of bean class [org.apache.commons.dbcp.BasicDataSource]: Bean property 'filters' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
18:15:49,723 ERROR DispatcherServlet:502 - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'filters' of bean class [org.apache.commons.dbcp.BasicDataSource]: Bean property 'filters' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
...全文
458 18 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
18 条回复
切换为时间正序
请发表友善的回复…
发表回复
lmkght 2016-12-27
  • 打赏
  • 举报
回复
如果还是报错dataSource 查一下都什么地方用到了 dataSource 对这些用到的地方排查一下就行了
lmkght 2016-12-27
  • 打赏
  • 举报
回复



改成dataSource
YafengLiang 2016-12-27
  • 打赏
  • 举报
回复
引用 9 楼 lmkght 的回复:
应该是ref="dataSource"吧
引用 9 楼 lmkght 的回复:
应该是ref="dataSource"吧
修改了,还是不对,报错一样
<!-- 创建jdbc数据源 -->
	<bean id="ds" class="org.springframework.jdbc.datasource.DriverManagerDataSource" >
		<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"></property>
		<property name="url" value="jdbc:oracle:thin:@192.168.6.25:1521:orcl"></property>
		<property name="username" value="scott"></property>
		<property name="password" value="tiger" ></property>
		
	</bean>
	<!-- 配置工厂sqlSsessionFactory -->
	<bean id ="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean" >
		<property name="dataSource" ref="ds"></property>
		<property name="mapperLocations" value="classpath:cn/voicecodes/entity/*.xml"></property>
	</bean>
ayou_java 2016-12-27
  • 打赏
  • 举报
回复
楼上正解,那里你是引入你配置的dataSource,用ref撒
lmkght 2016-12-27
  • 打赏
  • 举报
回复

应该是ref="dataSource"吧
YafengLiang 2016-12-27
  • 打赏
  • 举报
回复
引用 7 楼 sutongxuevip 的回复:
[quote=引用 6 楼 ayou_java 的回复:] Error creating bean with name 'dataSource' defined in class path resource [applicationContext.xml] 这里报错了, 1、你用的哪个连接池,name不要搞混淆了。 2、如果有用properties文件,是否有引入文件,注意文件里面的等号后面不能用空格。
Error creating bean with name 'dataSource' defined in class path resource [applicationContext.xml]: Error setting property values; 这句话就是说applicationContext.xml中 name为datasource的value有错误
<bean id= "dataSource" class="org.apache.commons.dbcp.BasicDataSource" >
		<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"></property>
		<property name="url" value="jdbc:oracle:thin:@127.0.0.2:1521:orcl"></property>
		<property name="username" value="scott"></property>
		<property name="password" value="tiger" ></property>
		
	</bean>
[/quote]
<!-- 配置工厂sqlSseesionFactory -->
	<bean id ="sqlSseesionFactory" class="org.mybatis.spring.SqlSessionFactoryBean" >
		<property name="dataSource" value="dataSource"></property>
		<property name="mapperLocations" value="classpath:cn/voicecodes/entity/*.xml"></property>
	</bean>
YafengLiang 2016-12-27
  • 打赏
  • 举报
回复
引用 6 楼 ayou_java 的回复:
Error creating bean with name 'dataSource' defined in class path resource [applicationContext.xml] 这里报错了, 1、你用的哪个连接池,name不要搞混淆了。 2、如果有用properties文件,是否有引入文件,注意文件里面的等号后面不能用空格。
Error creating bean with name 'dataSource' defined in class path resource [applicationContext.xml]: Error setting property values; 这句话就是说applicationContext.xml中 name为datasource的value有错误
<bean id= "dataSource" class="org.apache.commons.dbcp.BasicDataSource" >
		<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"></property>
		<property name="url" value="jdbc:oracle:thin:@127.0.0.2:1521:orcl"></property>
		<property name="username" value="scott"></property>
		<property name="password" value="tiger" ></property>
		
	</bean>
ayou_java 2016-12-27
  • 打赏
  • 举报
回复
Error creating bean with name 'dataSource' defined in class path resource [applicationContext.xml] 这里报错了, 1、你用的哪个连接池,name不要搞混淆了。 2、如果有用properties文件,是否有引入文件,注意文件里面的等号后面不能用空格。
YafengLiang 2016-12-27
  • 打赏
  • 举报
回复
引用 3 楼 qnmdcsdn 的回复:
连接池那里配置错了吧
<?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:mybatis="http://mybatis.org/schema/mybatis-spring"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:tx="http://www.springframework.org/schema/tx"
	xmlns:mvc="http://www.springframework.org/schema/mvc"
	xsi:schemaLocation="
	   http://www.springframework.org/schema/beans 
	   http://www.springframework.org/schema/beans/spring-beans.xsd  
       http://mybatis.org/schema/mybatis-spring 
       http://mybatis.org/schema/mybatis-spring.xsd  
       http://www.springframework.org/schema/context 
       http://www.springframework.org/schema/context/spring-context.xsd
       http://www.springframework.org/schema/tx 
       http://www.springframework.org/schema/tx/spring-tx.xsd
        http://www.springframework.org/schema/mvc
       http://www.springframework.org/schema/mvc/spring-mvc.xsd">

	<!-- 引入jdbc配置文件 -->
	<!-- <context:property-placeholder location="classpath:db.properties" /> -->
	<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" >
		<property name="location" value="classpath:db.properties"/>
	</bean>
	
	<!-- 创建jdbc数据源 -->
	<bean id= "dataSource" class="org.apache.commons.dbcp.BasicDataSource" >
		<property name="driverClassName" value="${driverClassName}"></property>
		<property name="url" value="${url}" ></property>
		<property name="username" value="${username} "></property>
		<property name="password" value="${password}" ></property>
		
	</bean>
	<!-- 配置工厂sqlSseesionFactory -->
	<bean id = "sqlSseesionFactory" class="org.mybatis.spring.SqlSessionFactoryBean" >
		<!-- <property name="configLocation" value="classpath:mybatis-cfg.xml"></property> -->
		<property name="dataSource" ref="dataSource"></property>
		<property name="mapperLocations" value="classpath:cn/voicecodes/entity/*.xml"></property>
	</bean>
	
	<!-- 配置Mybatis注解 -->
	<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer" > 
		<property name="basePackage" value="cn.voicecodes.dao"></property>
		<!-- <property name="annotationClass" value="cn.voicecodes.MybatisRepository" ></property> -->
	</bean>
	
	<!-- 开启注解扫描 -->
	<context:component-scan base-package="cn.voicecodes"/>
	
	<!-- 开启RequestMppering注解 -->
	<mvc:annotation-driven/>
	
	<!-- -->
	<bean class="org.springframework.web.servlet.view.InternalResourceView" >
		<property name="prefix" value="/WEN-INF/"/>
		<property name="suffix" value=".jsp"></property>
	</bean>
</beans> 
YafengLiang 2016-12-27
  • 打赏
  • 举报
回复
引用 3 楼 qnmdcsdn 的回复:
连接池那里配置错了吧
我再审查下。。
  • 打赏
  • 举报
回复
连接池那里配置错了吧
YafengLiang 2016-12-27
  • 打赏
  • 举报
回复
jar的问题,现在问题解决了,谢谢大家
lmkght 2016-12-27
  • 打赏
  • 举报
回复
现在报错应该跟‘filters‘这个东西有关 检查一下你用filters干嘛了?
lmkght 2016-12-27
  • 打赏
  • 举报
回复
filters是个什么? 你那个地方用ref 你就把上面的改回去 改成从db.properties加载属性的 然后看看你db.properties里写的对不 都正确了 应该能解决你ds中的value错误这个问题
YafengLiang 2016-12-27
  • 打赏
  • 举报
回复
引用 12 楼 lmkght 的回复:
改成dataSource
改成ds之后报的错是ds中的value错误, ds的引用是jdbc,jdbc中检查了,filters的错误不知道怎么处理,我在web.xml中设置了post的编码方式,其他地方没用到
bcsflilong 2016-12-27
  • 打赏
  • 举报
回复
operty 'filters' is not writable or has an invalid setter method. 缺少set 和get 方法
YafengLiang 2016-12-26
  • 打赏
  • 举报
回复
18:15:49,718 WARN XmlWebApplicationContext:550 - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'filters' of bean class [org.apache.commons.dbcp.BasicDataSource]: Bean property 'filters' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter? 18:15:49,723 ERROR DispatcherServlet:502 - Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'filters' of bean class [org.apache.commons.dbcp.BasicDataSource]: Bean property 'filters' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
YafengLiang 2016-12-26
  • 打赏
  • 举报
回复
查到的结果是commons-poll包错了,换了之后还是不行

67,549

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧