当我在 IntelliJ 上运行项目时,出现 java.io.IOException: org.xml.sax.SAXParseException 错误。
我找不到问题所在。有人可以帮我解决这个错误吗?
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
</web-app>
持久性.xml
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
version="2.1">
<persistence-unit name="aquadinePU" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/aquadine?autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=true" />
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="javax.persistence.jdbc.user" value="root" />
<property name="javax.persistence.jdbc.password" value="ruta" />
<property name="hibernate.show_sql" value="true"/>
</properties>
</persistence-unit>
</persistence>
web.xml的错误如下:
java.io.IOException: org.xml.sax.SAXParseExceptionpublicId: http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd; lineNumber: 1; columnNumber: 1; Deployment descriptor file WEB-INF/web.xml in archive [aquadine-jee]. Premature end of file.
persistence.xml的错误如下:
java.io.IOException: org.xml.sax.SAXParseExceptionpublicId: http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd; lineNumber: 1; columnNumber: 1; Deployment descriptor file META-INF/persistence.xml in archive [classes]. Premature end of file.
最佳答案
几天后我们也开始收到此错误。 URI:
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd
返回 SAX 解析器无法处理的状态代码 301。
我们的修补程序是将 web.xml 中的架构位置更改为新文件:
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://www.oracle.com/webfolder/technetwork/jsc/xml/ns/javaee/web-app_3_1.xsd
关于java - 在 glassfish 服务器中运行项目时出现 web.xml SAXParseException 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56736674/