SpringBoot项⽬jdk9运⾏报错,怎么处理都不⾏
jdk9与jdk8相⽐有很⼤的区别
JDK8:JDK8的部署是⼀个单体模式,即使项⽬内容少,也需要⼀整套的JRE环境。
JDK9:JDK9引⼊模块后,能将所有的类组织成模块形式。在新建项⽬时,不再需要整套的JRE环境。
并且jdk9在发布的时候有⼀些JDK8中的jar依赖没有集成进去,因此在使⽤⼀些版本的Spring Boot项⽬的时候就会报⼀些jar包缺失的错误。
ApplicationContextException:
Unable to embedded container; nested exception is BeanCreationException:jdk怎么使用
Error creating bean with'tomcatEmbeddedServletContainerFactory' defined in class path resource
[org/springframework/boot/autoconfigure/web/EmbeddedServletContainerAutoConfiguration$EmbeddedTomcat.class]:
Initialization of bean failed; nested exception is UnsatisfiedDependencyException: Error creating bean with'org.s pringframework.boot.autoconfigure.web.HttpEncodingAutoConfiguration':
Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with
'ding-org.springframework.boot.autoconfigure.web.HttpEncodingProperties': Initialization of bean
failed; nested exception is NoClassDefFoundError: javax/xml/bind/ValidationException; nested exception is B eanCreationException: Error creating bean with 'ding-
HttpEncodingProperties': Initialization of bean failed; nested exception is
NoClassDefFoundError: javax/xml/bind/ValidationException
根本的原因就是jdk9的jar包的缺失。
解决⽅法
在项⽬的l⽂件中引⼊缺失的jar包:
<!-- jdk9 缺失的jar包 -->
<dependency>
<groupId&l.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>l.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>l.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1.1</version>
</dependency>
然后重新启动项⽬!!
2022-02-2212:44:29.375 INFO 12020---[ main].RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repo sitory configuration mode!
2022-02-2212:44:29.375 INFO 12020---[ main].RepositoryConfigurationDelegate : Bootstrapping Spring Data Redis repositories in DEFAU LT mode.
2022-02-2212:44:29.423 INFO 12020---[ main].RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 27ms. Fou nd 0 Redis repository interfaces.
2022-02-2212:44:29.995 INFO 12020---[ main]TomcatWebServer : Tomcat initialized with(s):8082(http)
2022-02-2212:44:30.012 INFO 12020---[ main]StandardService : Starting service [Tomcat]
2022-02-2212:44:30.012 INFO 12020---[ main]StandardEngine : Starting Servlet engine:[Apache Tomcat/9.0.35]
启动成功!!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论