class 更改后如何在 Wildfly 中更新 MANIFEST
How to update MANIFEST in Wildfly when a class is changed
我用 Wildfly 安装了 Eclipse 和 Jboss 工具插件。我创建了一个 EAR 项目、一个 WAR 项目和两个 EJB jar 项目 app1
和 app2
。我将所有项目都转换为 Maven。
app1
使用 app2
的 class。这在 Eclipse 中编译得很好。但是当我 运行 应用程序时,我得到一个 ClassNotFoundException
。
EAR pom.xml 具有依赖项:
<dependencies>
<dependency>
<groupId>app1</groupId>
<artifactId>app1</artifactId>
<version>1.0</version>
<type>ejb</type>
</dependency>
<dependency>
<groupId>mywar</groupId>
<artifactId>mywar</artifactId>
<version>1.0</version>
<type>war</type>
</dependency>
<dependency>
<groupId>app2</groupId>
<artifactId>app2</artifactId>
<version>1.0</version>
<type>ejb</type>
</dependency>
</dependencies>
如果我在 MANIFEST 中将 app2.jar
添加到 app1
的 class 路径,app1
可以找到 class。问题是,当我在 app1
中更改 class 时,会自动重新创建 MANIFEST,删除 classpath.
这个有效:
Class-Path: app2-1.0.jar
我在 app1
pom.xml 中添加了一个插件,用于在 classes 更改时更新 MANIFEST,但它没有任何更改:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.1</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
</manifest>
<manifestEntries>
<Class-Path>app2-1.0.jar</Class-Path>
</manifestEntries>
</archive>
</configuration>
</plugin>
如何解决这个问题?
这解决了 app1 中的问题 pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.1</version>
<configuration>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<addClasspath>true</addClasspath>
</manifest>
<manifestEntries>
<Class-Path>app2-1.0.jar</Class-Path>
</manifestEntries>
</archive>
</configuration>
</plugin>
我用 Wildfly 安装了 Eclipse 和 Jboss 工具插件。我创建了一个 EAR 项目、一个 WAR 项目和两个 EJB jar 项目 app1
和 app2
。我将所有项目都转换为 Maven。
app1
使用 app2
的 class。这在 Eclipse 中编译得很好。但是当我 运行 应用程序时,我得到一个 ClassNotFoundException
。
EAR pom.xml 具有依赖项:
<dependencies>
<dependency>
<groupId>app1</groupId>
<artifactId>app1</artifactId>
<version>1.0</version>
<type>ejb</type>
</dependency>
<dependency>
<groupId>mywar</groupId>
<artifactId>mywar</artifactId>
<version>1.0</version>
<type>war</type>
</dependency>
<dependency>
<groupId>app2</groupId>
<artifactId>app2</artifactId>
<version>1.0</version>
<type>ejb</type>
</dependency>
</dependencies>
如果我在 MANIFEST 中将 app2.jar
添加到 app1
的 class 路径,app1
可以找到 class。问题是,当我在 app1
中更改 class 时,会自动重新创建 MANIFEST,删除 classpath.
这个有效:
Class-Path: app2-1.0.jar
我在 app1
pom.xml 中添加了一个插件,用于在 classes 更改时更新 MANIFEST,但它没有任何更改:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.1</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
</manifest>
<manifestEntries>
<Class-Path>app2-1.0.jar</Class-Path>
</manifestEntries>
</archive>
</configuration>
</plugin>
如何解决这个问题?
这解决了 app1 中的问题 pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.1</version>
<configuration>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<addClasspath>true</addClasspath>
</manifest>
<manifestEntries>
<Class-Path>app2-1.0.jar</Class-Path>
</manifestEntries>
</archive>
</configuration>
</plugin>