SpringBoot使用Jigsaw模块为java9

时间:2017-08-09 20:45:22

标签: spring-boot java-9 jigsaw

我正在尝试编写一个简单的Spring启动应用程序,我可以使用Java 9运行。我无法在jdk9下编译此应用程序。 我在记录模块时遇到了大量错误

有没有人在jdk9 jigsaw概念下有任何使用Springboot的示例应用程序?

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.6.1:compile (default-compile) on project JigsawTest: Compilation failure: Compilation failure: 
[ERROR] the unnamed module reads package org.apache.commons.logging from both spring.jcl and jcl.over.slf4j
[ERROR] module spring.aop reads package org.apache.commons.logging from both spring.jcl and jcl.over.slf4j
[ERROR] module spring.context reads package org.apache.commons.logging from both spring.jcl and jcl.over.slf4j
[ERROR] module spring.beans reads package org.apache.commons.logging from both spring.jcl and jcl.over.slf4j
[ERROR] module spring.core reads package org.apache.commons.logging from both spring.jcl and jcl.over.slf4j
[ERROR] module spring.web reads package org.apache.commons.logging from both spring.jcl and jcl.over.slf4j
[ERROR] module spring.jcl reads package org.apache.commons.logging from both spring.jcl and jcl.over.slf4j
[ERROR] module spring.boot.starter.web reads package org.apache.commons.logging from both spring.jcl and jcl.over.slf4j
[ERROR] module spring.boot.starter reads package org.apache.commons.logging from both spring.jcl and jcl.over.slf4j
[ERROR] module spring.boot.starter.logging reads package org.apache.commons.logging from both spring.jcl and jcl.over.slf4j
[ERROR] module logback.classic reads package org.apache.commons.logging from both spring.jcl and jcl.over.slf4j
[ERROR] module logback.core reads package org.apache.commons.logging from both spring.jcl and jcl.over.slf4j
[ERROR] module slf4j.api reads package org.apache.commons.logging from both spring.jcl and jcl.over.slf4j
[ERROR] module jcl.over.slf4j reads package org.apache.commons.logging from both spring.jcl and jcl.over.slf4j
[ERROR] module jul.to.slf4j reads package org.apache.commons.logging from both spring.jcl and jcl.over.slf4j
[ERROR] module log4j.over.slf4j reads package org.apache.commons.logging from both spring.jcl and jcl.over.slf4j
[ERROR] module spring.boot.starter.tomcat reads package org.apache.commons.logging from both spring.jcl and jcl.over.slf4j
[ERROR] module tomcat.embed.core reads package org.apache.commons.logging from both spring.jcl and jcl.over.slf4j
[ERROR] module tomcat.embed.el reads package org.apache.commons.logging from both spring.jcl and jcl.over.slf4j
[ERROR] module tomcat.embed.websocket reads package org.apache.commons.logging from both spring.jcl and jcl.over.slf4j
[ERROR] module hibernate.validator reads package org.apache.commons.logging from both spring.jcl and jcl.over.slf4j
[ERROR] module validation.api reads package org.apache.commons.logging from both spring.jcl and jcl.over.slf4j
[ERROR] module jboss.logging reads package org.apache.commons.logging from both spring.jcl and jcl.over.slf4j
[ERROR] module classmate reads package org.apache.commons.logging from both spring.jcl and jcl.over.slf4j
[ERROR] module jackson.databind reads package org.apache.commons.logging from both spring.jcl and jcl.over.slf4j
[ERROR] module jackson.annotations reads package org.apache.commons.logging from both spring.jcl and jcl.over.slf4j
[ERROR] module jackson.core reads package org.apache.commons.logging from both spring.jcl and jcl.over.slf4j
[ERROR] module spring.webmvc reads package org.apache.commons.logging from both spring.jcl and jcl.over.slf4j
[ERROR] module spring.expression reads package org.apache.commons.logging from both spring.jcl and jcl.over.slf4j
[ERROR] module spring.boot reads package org.apache.commons.logging from both spring.jcl and jcl.over.slf4j
[ERROR] module spring.boot.autoconfigure reads package org.apache.commons.logging from both spring.jcl and jcl.over.slf4j

Here is the link to my sample project in github

2 个答案:

答案 0 :(得分:2)

看起来像:

  1. 所有JAR最终都在模块路径上(奇怪)
  2. spring.jcl jcl.over.slf4j 包含大量相同的包
  3. 如果您无法修复1.,请尝试通过排除两个工件中的一个来解决问题。

答案 1 :(得分:2)

我能够通过示例来编译here。此时mvn clean package使用Maven 3.5.0。请注意,我没有尝试过运行该应用程序。

请注意,我做了以下更改:

按照惯例,源代码现在位于与模块名称匹配的文件夹中。

~/com.allstate.jigsaw/src/main/java/...

module-info.java文件已简化:

module com.allstate.jigsaw {
    requires java.logging;

    requires spring.boot;
}

此外,pom.xml已经过修改以使用Java 9.根目录中有父pom.xml,模块文件夹中有另一个父com.allstate.jigsaw/pom.xml。以下是<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <version>1.5.6.RELEASE</version> </dependency>

中的主要依赖项
WKWebView