linux下执行java -jar命令时报错:cvc-elt.1: Cannot find the declaration of element 'beans'

在本地windows下的intellij idea中开发的maven项目,使用spring框架,JavaSE项目,作用是数据清洗。

在本地windows下 java -jar命令没有问题,但是部署到linux后,执行java -jar命令报错

cvc-elt.1: Cannot find the declaration of element 'beans'

原因是:

applicationContext.xml中配置文件有问题

xsi:schemaLocation 的xsd要指定具体依赖包中的版本,并指定具体位置

修改为:

<?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:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans
       classpath:/org/springframework/beans/factory/xml/spring-beans-4.3.xsd
       http://www.springframework.org/schema/context
       classpath:/org/springframework/context/config/spring-context-3.1.xsd">

参考:cvc-elt.1: Cannot find the declaration of element 'beans'

猜你喜欢

转载自blog.csdn.net/u013905744/article/details/81745669