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?
...全文
456 18 打赏 收藏 转发到动态 举报
写回复
用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包错了,换了之后还是不行
部署说明 项目启动后,在浏览器中访问地址:http://127.0.0.1:8080/personnel/ 我录了一个视频来演示一下,人事管理系统部署视频链接:https://www.bilibili.com/video/av53594307/ 基础环境:JDK8,Tomcat8,MySQL5.7 报错可以查看我的教程:我的教程 加入了普通用户的功能,在登陆时可以选择,可以查询职位,部门,公告,文档,但不能对其他的进行修改。使用JavaEE开发,基于SpringMVC+Mybatis框架,该项目包含了用户管理、部门管理、职位管理、员工管理、公告管理、下载中心等多个模块,页面使用JQuery框架完成动态功能,用户管理、部门管理等模块包含了项目开发中常用的增删改查动作,下载中心包含了 Spring MVC的文件上传、下载等功能。 系统功能介绍 用户管理的功能包括:添加用户,用户可以为管理员或者普通用户;查询用户,可以查询所有用户或根据用户名和用户状态进行模糊查询,删除用户,修改用户。 部门管理的功能包括:添加部门,查询部门,可以查询所有部门或根据部门名称进行模糊查询,删除部门,修改部门 职位管理的功能包括:添加职位,查询职位,可以查询所有职位或根据职位名称进行模糊查询,删除职位,修改职位 员工管理的功能包括:添加员工,查询员工,可以查询所有员工或根据员工姓名,身份证号,手机号,性别,职位,部门进行模查询,删除员工,修改员工。 公告管理的功能包括:添加公告,查询公告,可以查询所有公告或根据公告名称,公告内容进行模糊查询,删除公告,修改公告。 下载中心的功能包括:上传文件,查淘文件,可以查询所有文件或根据文件标题进行模糊查询,预览文件内容:删除文件,下载文件。

67,515

社区成员

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

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