关于spring tool suite中的web.xml的首行错误Referenced file contains errors (http://java.sun.com/xml/ns/javaee/

最近因为毕业设计匆忙学习了SSM框架,在看了各种资料后真心推荐B站的DT课堂的颜群老师的视频,适合有一定计算机基础但又没学习过servlet和ssm框架的人群

使用spring tool suite4开发web项目时,发现没有spring bean configuration file,并且生成的web.xml中显示

1 referenced file contains errors (http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd). For more information, right 
 click on the message in the Problems View and select "Show Details..."

2  web.xml中还显示<display-name>错误,显示invalid element

先解决没有spring bean configuration file的问题,在网上找了两个解决方案

https://blog.csdn.net/sqzhao/article/details/88393045?depth_1-utm_source=distribute.pc_relevant.none-task&utm_source=distribute.pc_relevant.none-task

如上图所示,但因为spring roo的下载速度实在是太慢了,于是我重新下载了spring tool suite3

下载地址:https://github.com/spring-projects/toolsuite-distribution/wiki/Spring-Tool-Suite-3

安装了sts3之后,发现有了spring bean configuration file,并且之前提醒的referenced file contains errors(http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd)也不见了

安装sts3之后,记得重新部署tomcat和修改默认编码方式为UTF-8(Window-->Preferences--->General-->Workspace”,Eclipse默认GBK编码,选中“Other”,切换UTF-8)如果要单独修改项目的编码方式,则右键Properties-->Resource,右边栏中选中“Other”,切换编码为UTF-8


referenced file contains errors错误可以修改

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns="http://java.sun.com/xml/ns/javaee" 
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
id="WebApp_ID" 
version="2.5">

 

将javaee改成java2e,再进行保存,错误就不见了


在用sts3进行开发后,又遇到了问题

用全局配置mapper文件后

 <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
	 	<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property>
	 	<property name="basePackage" value="org.cc.mapper"></property>

在applicationContext.xml中中为service注入mapper(dao)

<!-- 依赖注入:给service注入dao -->
	<bean id="userService" class="org.cc.service.impl.UserServiceImpl">
		<property name="userMapper"  ref="userMapper"></property>
	</bean>

后显示错误Multiple annotations found at this line:
    - Referenced bean 'userMapper' not found
    - No setter found for property 'userMapper' in class 

但我明明在UserServiceImpl文件中写了setter,也全局配置了mapper。

最后将环境换到spring tool suite4中,同样的代码,就没有错误了


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值