Spring boot JPMS/Jigsaw Keyclope弹簧引导启动器(模块名称和解析异常无效)
Java11Maven应用程序是用JPMS/Jigsaw模块化的 问题1:keydape-spring-boot-2-adapter模块名“2”无效 解决方案1:由maven插件重命名,删除“-2”。但我不确定这是否是一个好的解决方案Spring boot JPMS/Jigsaw Keyclope弹簧引导启动器(模块名称和解析异常无效),spring-boot,maven,keycloak,java-platform-module-system,Spring Boot,Maven,Keycloak,Java Platform Module System,Java11Maven应用程序是用JPMS/Jigsaw模块化的 问题1:keydape-spring-boot-2-adapter模块名“2”无效 解决方案1:由maven插件重命名,删除“-2”。但我不确定这是否是一个好的解决方案 <plugin> <!-- for copying dependent libraries to folder lib --> <groupId>org.apache.maven.plugins</groupI
<plugin>
<!-- for copying dependent libraries to folder lib -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>../lib</outputDirectory>
<excludeGroupIds>com.xyz</excludeGroupIds>
<excludeArtifactIds>keycloak-spring-boot-2-adapter</excludeArtifactIds>
</configuration>
</execution>
<execution>
<id>copy</id>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifacItem>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-spring-boot-2-adapter</artifactId>
<overWrite>true</overWrite>
<outputDirectory>../lib</outputDirectory>
<destFileName>keycloak-spring-boot-adapter-9.0.2.jar</destFileName>
</artifacItem>
</artifactItems>
<!-- other configurations here -->
</configuration>
</execution>
</executions>
</plugin>
解决方案2:
谢谢你的帮助和问候
Pierre有一张罚单(),上面有两个子任务,描述了您面临的两个问题:(问题1)和(问题2)
第一个问题是一个微不足道的问题,无论是从您的角度还是从KeyClope的维护者的角度来看
但是,第二个问题需要更多的工作,因为两个(实际上是三个)工件共享同一个包,并在用作自动模块时导出它(因为自动模块导出其所有包)。但是,不允许从多个模块导出相同的包()。
这个问题涉及的三个工件是,和。适配器核心工件的工作方式有点像其他两个模块的抽象实现,并提供其他两个模块使用的包私有类和方法。
强调的文本是第二个问题的核心:跨不同工件共享包对于没有模块的经典Java是有效的,但是模块系统阻止了这一点,因为它破坏了封装。
解决第二个问题需要您复制
keydove-spring-boot-adapter core
和keydove-spring-boot-2-adapter
,并调整它们的代码-至少直到官方工件得到修复为止。有一张罚单(),其中有两个子任务描述您面临的两个问题:(问题1)和(问题2)
第一个问题是一个微不足道的问题,无论是从您的角度还是从KeyClope的维护者的角度来看
但是,第二个问题需要更多的工作,因为两个(实际上是三个)工件共享同一个包,并在用作自动模块时导出它(因为自动模块导出其所有包)。但是,不允许从多个模块导出相同的包()。
此问题涉及的三个工件是、和。适配器核心工件的工作方式有点像其他两个模块的抽象实现,并提供其他两个模块使用的包私有类和方法。
强调的文本是第二个问题的核心:跨不同工件共享包对于没有模块的经典Java是有效的,但是模块系统阻止了这一点,因为它破坏了封装。
解决第二个问题需要您复制
keydove-spring-boot-adapter core
和keydove-spring-boot-2-adapter
并调整它们的代码-至少在修复官方工件之前。问题2的解决方案是构建自己的自动模块
创建一个新模块并添加一个POM,其中包含以下构建插件和依赖项
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-spring-boot-2-adapter</artifactId>
<version>9.0.2</version>
<exclusions>
<exclusion>
<groupId> org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
...
</exclusions>
</dependency>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
</plugin>
<!-- Maven Assembly Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<!-- get all project dependencies -->
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<appendAssemblyId>false</appendAssemblyId>
<outputDirectory>../mods</outputDirectory>
<archive>
<manifestEntries>
<Automatic-Module-Name>modulename</Automatic-Module-Name>
</manifestEntries>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
<executions>
<execution>
<id>install-external</id>
<phase>install</phase>
<configuration>
<file>${project.basedir}/../mods/modulename-1.0-SNAPSHOT.jar</file>
<repositoryLayout>default</repositoryLayout>
<groupId>com.xyz.assembly</groupId>
<artifactId>modulename</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<generatePom>true</generatePom>
</configuration>
<goals>
<goal>install-file</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
密钥斗篷
Keyclope-spring-boot-2适配器
9.0.2
org.slf4j
slf4j api
...
org.apache.maven.plugins
maven清洁插件
org.apache.maven.plugins
maven汇编插件
3.1.1
带有依赖项的jar
假的
../mods
模块名
组装
包裹
单一的
org.apache.maven.plugins
maven安装插件
2.5.2
安装外部
安装
${project.basedir}/./mods/modulename-1.0-SNAPSHOT.jar
违约
com.xyz.assembly
模块名
1.0-快照
罐子
真的
安装文件
您可以通过com.xyz.assembly将依赖项作为groupID添加到其他模块
但要保持注意力!
如果您不在此组装模块中排除它,它将使用log4j的module-info.java。问题2的解决方案是构建自己的自动模块 创建一个新模块并添加一个POM,其中包含以下构建插件和依赖项
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-spring-boot-2-adapter</artifactId>
<version>9.0.2</version>
<exclusions>
<exclusion>
<groupId> org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
...
</exclusions>
</dependency>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
</plugin>
<!-- Maven Assembly Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<!-- get all project dependencies -->
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<appendAssemblyId>false</appendAssemblyId>
<outputDirectory>../mods</outputDirectory>
<archive>
<manifestEntries>
<Automatic-Module-Name>modulename</Automatic-Module-Name>
</manifestEntries>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
<executions>
<execution>
<id>install-external</id>
<phase>install</phase>
<configuration>
<file>${project.basedir}/../mods/modulename-1.0-SNAPSHOT.jar</file>
<repositoryLayout>default</repositoryLayout>
<groupId>com.xyz.assembly</groupId>
<artifactId>modulename</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<generatePom>true</generatePom>
</configuration>
<goals>
<goal>install-file</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
密钥斗篷
Keyclope-spring-boot-2适配器
9.0.2
org.slf4j
slf4j api
...
org.apache.maven.plugins
maven清洁插件
org.apache.maven.plugins
maven汇编插件
3.1.1
带有依赖项的jar
假的
../mods
模块名
组装
包裹
单一的
org.apache.maven.plugins
maven安装插件