gpt4 book ai didi

java - Spring MVC - HTTP 状态 500

转载 作者:行者123 更新时间:2023-11-28 23:16:39 24 4
gpt4 key购买 nike

好的,我在运行我的应用程序时遇到了这个问题,我相信这是因为版本控制。

初秋,我使用的是 Tomcat 9.0.4。我正在使用最新的 Java SDK。

现在,我使用的是 Spring 版本 5.0.2。

这是我的 pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.mvctest</groupId>
<artifactId>FirstMvcApp</artifactId>
<version>1.0-SNAPSHOT</version>

<packaging>war</packaging>

<properties>
<spring.version>5.0.2.RELEASE</spring.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
</dependencies>
</project>

这是我的 web.xml:

<?xml version="1.0" encoding="UTF-8" ?>

<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xli="http://www.w3.org/2001/XMLSchema-instance"
xli:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">

<display-name>FirstMvcApp</display-name>

<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/dispatcher-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>

</web-app>

这是我的 dispatcher-servlet.xml:

<?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"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-5.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/spring-mvc-5.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/spring-context-5.0.xsd">

<context:component-scan base-package="com.firstwebapp.controllers" />

<mvc:annotation-driven/>

<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/"/>
<property name="suffix" value=".jsp"/>
</bean>
</beans>

现在,我想提一提:看到dispatcher-servlet中的那些/spring-**-5.0.xsd了吗?我不确定这是否正确。为什么?好吧,这是我在输出中遇到的错误:

C:\JavaWebServers\apache-tomcat-9.0.4\bin\catalina.bat run
[2018-02-01 10:38:56,961] Artifact FirstMvcApp:war exploded: Waiting for server connection to start artifact deployment...
Using CATALINA_BASE: "C:\Users\germmand\.IntelliJIdea2017.3\system\tomcat\Unnamed_FirstMvcApp"
Using CATALINA_HOME: "C:\JavaWebServers\apache-tomcat-9.0.4"
Using CATALINA_TMPDIR: "C:\JavaWebServers\apache-tomcat-9.0.4\temp"
Using JRE_HOME: "C:\Program Files\Java\jdk-9.0.1"
Using CLASSPATH: "C:\JavaWebServers\apache-tomcat-9.0.4\bin\bootstrap.jar;C:\JavaWebServers\apache-tomcat-9.0.4\bin\tomcat-juli.jar"
01-Feb-2018 22:38:58.042 INFORMACIÓN [main] org.apache.catalina.startup.VersionLoggerListener.log Server version: Apache Tomcat/9.0.4
01-Feb-2018 22:38:58.044 INFORMACIÓN [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Jan 18 2018 19:42:17 UTC
01-Feb-2018 22:38:58.044 INFORMACIÓN [main] org.apache.catalina.startup.VersionLoggerListener.log Server number: 9.0.4.0
01-Feb-2018 22:38:58.044 INFORMACIÓN [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Windows 10
01-Feb-2018 22:38:58.044 INFORMACIÓN [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 10.0
01-Feb-2018 22:38:58.044 INFORMACIÓN [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: amd64
01-Feb-2018 22:38:58.044 INFORMACIÓN [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home: C:\Program Files\Java\jdk-9.0.1
01-Feb-2018 22:38:58.046 INFORMACIÓN [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 9.0.1+11
01-Feb-2018 22:38:58.046 INFORMACIÓN [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: Oracle Corporation
01-Feb-2018 22:38:58.047 INFORMACIÓN [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: C:\Users\germmand\.IntelliJIdea2017.3\system\tomcat\Unnamed_FirstMvcApp
01-Feb-2018 22:38:58.047 INFORMACIÓN [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: C:\JavaWebServers\apache-tomcat-9.0.4
01-Feb-2018 22:38:58.048 INFORMACIÓN [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.lang=ALL-UNNAMED
01-Feb-2018 22:38:58.048 INFORMACIÓN [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
01-Feb-2018 22:38:58.048 INFORMACIÓN [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=C:\Users\germmand\.IntelliJIdea2017.3\system\tomcat\Unnamed_FirstMvcApp\conf\logging.properties
01-Feb-2018 22:38:58.048 INFORMACIÓN [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
01-Feb-2018 22:38:58.048 INFORMACIÓN [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote=
01-Feb-2018 22:38:58.048 INFORMACIÓN [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.port=1099
01-Feb-2018 22:38:58.048 INFORMACIÓN [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.ssl=false
01-Feb-2018 22:38:58.050 INFORMACIÓN [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.authenticate=false
01-Feb-2018 22:38:58.050 INFORMACIÓN [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.rmi.server.hostname=127.0.0.1
01-Feb-2018 22:38:58.050 INFORMACIÓN [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
01-Feb-2018 22:38:58.050 INFORMACIÓN [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
01-Feb-2018 22:38:58.050 INFORMACIÓN [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dignore.endorsed.dirs=
01-Feb-2018 22:38:58.050 INFORMACIÓN [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=C:\Users\germmand\.IntelliJIdea2017.3\system\tomcat\Unnamed_FirstMvcApp
01-Feb-2018 22:38:58.051 INFORMACIÓN [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=C:\JavaWebServers\apache-tomcat-9.0.4
01-Feb-2018 22:38:58.051 INFORMACIÓN [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=C:\JavaWebServers\apache-tomcat-9.0.4\temp
01-Feb-2018 22:38:58.051 INFORMACIÓN [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent La biblioteca nativa de Apache Tomcat basada en ARP que permite un rendimiento óptimo en entornos de desarrollo no ha sido hallada en java.library.path: [C:\Program Files\Java\jdk-9.0.1\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Git\cmd;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\Java\jdk-9.0.1\bin;C:\Program Files\Java\jre-9.0.1\bin;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\;C:\Program Files\Microsoft SQL Server\140\Tools\Binn\;C:\Program Files\Microsoft SQL Server\140\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\140\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\ManagementStudio\;C:\Program Files\nodejs\;C:\Users\germmand\AppData\Local\Microsoft\WindowsApps;C:\Users\germmand\AppData\Roaming\npm;C:\Program Files\Microsoft VS Code\bin;.]
01-Feb-2018 22:38:58.091 INFORMACIÓN [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
01-Feb-2018 22:38:58.106 INFORMACIÓN [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
01-Feb-2018 22:38:58.113 INFORMACIÓN [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"]
01-Feb-2018 22:38:58.115 INFORMACIÓN [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
01-Feb-2018 22:38:58.115 INFORMACIÓN [main] org.apache.catalina.startup.Catalina.load Initialization processed in 445 ms
01-Feb-2018 22:38:58.174 INFORMACIÓN [main] org.apache.catalina.core.StandardService.startInternal Arrancando servicio [Catalina]
01-Feb-2018 22:38:58.175 INFORMACIÓN [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/9.0.4
01-Feb-2018 22:38:58.182 INFORMACIÓN [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
01-Feb-2018 22:38:58.191 INFORMACIÓN [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"]
01-Feb-2018 22:38:58.195 INFORMACIÓN [main] org.apache.catalina.startup.Catalina.start Server startup in 79 ms
Connected to server
[2018-02-01 10:38:58,540] Artifact FirstMvcApp:war exploded: Artifact is being deployed, please wait...
01-Feb-2018 22:38:59.902 INFORMACIÓN [RMI TCP Connection(3)-127.0.0.1] org.apache.jasper.servlet.TldScanner.scanJars Al menos un JAR, que se ha explorado buscando TLDs, aún no contenía TLDs. Activar historial de depuración para este historiador para una completa lista de los JARs que fueron explorados y de los que nos se halló TLDs. Saltarse JARs no necesarios durante la exploración puede dar lugar a una mejora de tiempo significativa en el arranque y compilación de JSP .
01-Feb-2018 22:39:00.172 INFORMACIÓN [RMI TCP Connection(3)-127.0.0.1] org.springframework.web.servlet.FrameworkServlet.initServletBean FrameworkServlet 'dispatcher': initialization started
01-Feb-2018 22:39:00.216 INFORMACIÓN [RMI TCP Connection(3)-127.0.0.1] org.springframework.context.support.AbstractApplicationContext.prepareRefresh Refreshing WebApplicationContext for namespace 'dispatcher-servlet': startup date [Thu Feb 01 22:39:00 VET 2018]; root of context hierarchy
01-Feb-2018 22:39:00.282 INFORMACIÓN [RMI TCP Connection(3)-127.0.0.1] org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions Loading XML bean definitions from ServletContext resource [/WEB-INF/dispatcher-servlet.xml]
01-Feb-2018 22:39:01.106 ADVERTENCIA [RMI TCP Connection(3)-127.0.0.1] org.springframework.util.xml.SimpleSaxErrorHandler.warning Ignored XML validation warning
org.xml.sax.SAXParseException; lineNumber: 8; columnNumber: 137; schema_reference.4: Fallo al leer el documento de esquema 'http://www.springframework.org/schema/beans/spring-beans-5.0.xsd', porque 1) no se ha encontrado el documento; 2) no se ha podido leer el documento; 3) el elemento raíz del documento no es <xsd:schema>.
at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:204)
at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.warning(ErrorHandlerWrapper.java:100)
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:391)
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:305)
at java.xml/com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.reportSchemaErr(XSDHandler.java:4207)
at java.xml/com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.reportSchemaWarning(XSDHandler.java:4198)
at java.xml/com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.getSchemaDocument1(XSDHandler.java:2512)
at java.xml/com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.getSchemaDocument(XSDHandler.java:2210)
at java.xml/com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.parseSchema(XSDHandler.java:584)
at java.xml/com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadSchema(XMLSchemaLoader.java:619)
at java.xml/com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.findSchemaGrammar(XMLSchemaValidator.java:2709)
at java.xml/com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:2068)
at java.xml/com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:828)
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:374)
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl$NSContentDriver.scanRootElementHook(XMLNSDocumentScannerImpl.java:613)
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:3058)
AND GOES ON...

现在,我知道这是一大段文字,您可能不会阅读它。问题从这里开始:

org.springframework.util.xml.SimpleSaxErrorHandler.warning Ignored XML validation warning
org.xml.sax.SAXParseException; lineNumber: 8; columnNumber: 137; schema_reference.4: Fallo al leer el documento de esquema 'http://www.springframework.org/schema/beans/spring-beans-5.0.xsd', porque 1) no se ha encontrado el documento; 2) no se ha podido leer el documento; 3) el elemento raíz del documento no es <xsd:schema>.

翻译成英文是这样说的:' http://www.springframework.org/schema/beans/spring-beans-5.0.xsd ' 要么无法找到,要么无法读取,或者文档的根目录不是“xsd:schema”。

这是我在浏览器中得到的图片: enter image description here

最佳答案

在 pom.xml 中包含以下 maven 依赖

     <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>

关于java - Spring MVC - HTTP 状态 500,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48574987/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com