Java Spring服务器无法启动
我不久前有一个Spring项目。它在我的旧服务器上运行得很好。然而,在更现代的服务器上,我似乎无法让它运行。这是我运行mvn spring boot:run时得到的:Java Spring服务器无法启动,java,spring,maven,Java,Spring,Maven,我不久前有一个Spring项目。它在我的旧服务器上运行得很好。然而,在更现代的服务器上,我似乎无法让它运行。这是我运行mvn spring boot:run时得到的: path resource [org/springframework/boot/autoconfigure/web/EmbeddedServletContainerAutoConfiguration$ EmbeddedTomcat.class]: Initialization of bean failed; nested exc
path resource [org/springframework/boot/autoconfigure/web/EmbeddedServletContainerAutoConfiguration$
EmbeddedTomcat.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.boot.autoconfigure.web.ServerProperties org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration.properties; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'serverProperties' defined in class path resource [org/springframework/boot/autoconfigure/web/ServerPropertiesAutoConfiguration.class]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/ValidationException: javax.xml.bind.ValidationException ->
我使用的是Maven,下面是pom.xml
依赖项
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.5.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.3</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4.6</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<optional>true</optional>
</dependency>
</dependencies>
org.springframework.boot
spring启动程序父级
1.3.5.1发布
org.apache.httpcomponents
httpclient
4.5.3
真的
org.apache.httpcomponents
httpcore
4.4.6
真的
公用记录
公用记录
1.1.1
真的
org.springframework.boot
SpringBootStarterWeb
真的
朱尼特
朱尼特
4.11
真的
它是一个很大的
pom.xml
,但有点多余。JDK 9及更高版本从JDK中删除了一些xml包。最有可能的是,您的旧服务器运行在JDK 8上,其中包括这些包。在JDK 11上运行应用程序时,现在需要将它们作为依赖项添加。将此项添加到依赖项应该可以解决此问题:
<!-- API, java.xml.bind module -->
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>2.3.2</version>
</dependency>
<!-- Runtime, com.sun.xml.bind module -->
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.3.2</version>
</dependency>
jakarta.xml.bind
jakarta.xml.bind-api
2.3.2
org.glassfish.jaxb
jaxb运行时
2.3.2
您使用哪个版本的JDK编译这个项目?@IshikawaYoshiOpenJDK运行时环境(build 11.0.9.1+1-Ubuntu-0ubuntu1.20.10)
您能检查一下这个答案吗?我想它与您的问题有关。java.lang.NoClassDefFoundError:javax/xml/bind/ValidationException:javax.xml.bind.ValidationException据我所知,SpringBoot2.1.0支持java 11这里还有一个有用的链接