代码之家  ›  专栏  ›  技术社区  ›  ps0604

如何在类更改时更新Wildfly中的清单

  •  0
  • ps0604  · 技术社区  · 6 年前

    我用wildfly安装了eclipse和jboss工具插件。我创建了一个ear项目、一个war项目和两个ejb jars项目 app1 app2 . 我把所有的项目都转换成了maven。

    APP1 使用一类 APP2 . 这在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>
    

    如果我添加 app2.jar 到的类路径 APP1 在名单上, APP1 能找到班级。问题是当我在 APP1 ,将自动重新创建清单,并删除类路径。

    这工作:

     Class-Path: app2-1.0.jar
    

    我添加到 APP1 pom.xml一个插件,用于在类更改时更新清单,但它不会更改任何内容:

            <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>  
    

    如何解决这个问题?

    1 回复  |  直到 6 年前
        1
  •  0
  •   ps0604    6 年前

    这解决了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>