1、在Java 9上使用Spring Boot
问题描述:
- 1、新建Spring Boot项目默认版本是
1.5.9
,导致不能运行 - 2、java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
解决方案:
其实这两个问题Spring Boot在Github上已经就Java 9的问题,做了十分详细的描述。原文Spring Boot with Java 9
对于第一个问题,就是需要使用2.x的版本。原文中是这样说的:
Spring Boot 2 is the first version to support Java 9 (Java 8 is also supported). If you are using 1.5 and wish to use Java 9 you should upgrade to 2.0 as we have no plans to support Java 9 on Spring Boot1.5.x
.第二个问题啊,新建的项目不会遇到,但是我在写了一些东西之后就出现了这个问题。解决方案如下:
Hibernate typically requires JAXB that’s no longer provided by default. You either need to add a dependency to your project:
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
</dependency>
Or you could add the java.xml.bind module to restore this functionality with Java9.