然后我原本代码是
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.springframework.org/schema/beans/spring-beans-4.2.xsd" xsi:schemaLocation="http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
http://www.springframework.org/schema/beans/spring-beans-4.2.xsd">
<!-- 将User对象交给spring容器管理 -->
<bean name="user" class="bean.User"></bean>
</beans>
报如上错误,参考网上建议
- 修改为classpath那个格式的 不ok,报新的错误,和原本应该的不符合
- 前面加个<!DOCTYPE那一堆的 也不ok,还是原来的错误
然后看了看提供的xsd,发现官方代码是这么写的
<xsd:schema xmlns="http://www.springframework.org/schema/beans"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.springframework.org/schema/beans">
试着改了改,把beans后面的也都删掉了,还是不ok,提示publicID和systemID需要空格
然后我就去搜了一下需要空格的话咋整,嗯,没找到
但是又从官方文档得出了灵感,可以加个回车?好像还不行,但是比之前的最起码有头脑了一些,大胆改了一下,如下,通过√ 其他格式还是不能通过,咱也不知道为啥我环境这么奇葩,还不配合一下网上的答案,留个博客加以记录
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.springframework.org/schema/beans" xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.2.xsd">
<!-- 将User对象交给spring容器管理 -->
<bean name="user" class="bean.User"></bean>
</beans>
今天收工啦