SpringBoot为java9使用拼图模块
我想写一个简单的弹簧启动应用程序,我可以使用Java 9运行。我无法在jdk9下编译此应用程序。 我在记录模块周围出现一堆错误SpringBoot为java9使用拼图模块
有没有人有任何使用jdk9拼图概念下的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
它看起来像:
- 所有JAR最终模块路径(怪异)
- spring.jcl和jcl.over.slf4j上包含很多相同的包裹
如果您无法修复1.,请尝试解决2.通过排除两个工件之一。
是的。谢谢。我做到了。它的工作。 – Jay
我能够到这个例子来编译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>
谢谢。感谢帮助。但是,运行这需要一些额外的工作。我必须在spring-boot-starter artifact中排除org.slf4j才能实现它。 – Jay
请阅读有关如何提出一个好问题的常见问题 - https://*.com/help/how-to-ask。一些明显的问题:您使用的是什么版本的Maven?你可以分享pom.xml吗?你在使用什么版本的Spring Boot? –