我想运行一个 Java-Applet。 我使用 JBoss 服务器。 我使用Maven。 我使用Eclipse。 我使用 Eclipse 将企业存档内的 Web 存档部署到服务器上。
对于 Applet,我需要 Applet 的 .class 文件位于 applet.html 的可访问文件夹中。 我的想法是将 .class-从目标文件夹复制到我的网络存档的资源文件夹中。因此,我将以下插件添加到 Web-Maven-Project 的 pom.xml 中:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4</version>
<goals>
<goal>deploy</goal>
</goals>
<executions>
<execution>
<id>copy-applet-related-classes</id>
<phase>package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/LMS-Admin-Web- 0.0.1/resources/applet</outputDirectory>
<resources>
<resource>
<directory>${basedir}/target/classes/de/test/lms/applet</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
我认为我搞乱了阶段和目标。当我为包设定了“安装”目标并在项目文件夹中执行“mvn clean install”时,它起作用了一次。问题是当我在 Eclipse 中使用右键单击->发布时。我不知道,比什么目标都跑。我尝试了很多,但它不适用于 JBoss 的独立/部署/...文件系统。 事实证明,这也很难用谷歌搜索。因此,我将感谢任何想法、链接或其他帮助!
编辑: 我发现,当我发布时,目标文件夹中的类文件夹被编辑,但打包到 WAR 文件中的 WEB 文件夹却没有编辑。也许我需要一个阶段,即包装之前?我明天将进一步调查。
最佳答案
在我的项目中,我还需要一个小程序,需要将其复制到 classes
目录中。唯一的区别是我将小程序存储为 Artifact (因此存储在 jar 中)。我正在使用 process-resources
阶段。在你的情况下也可能如此。
如果您想打包您的小程序,我将添加我的解决方案。如果您愿意,您需要这样做 sign it .
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<id>copy-signed-applet</id>
<phase>process-resources</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>mygroupid</groupId>
<artifactId>myapplet</artifactId>
<version>${myapplet.version}</version>
<outputDirectory>${project.build.outputDirectory}/path/to/applet</outputDirectory>
<destFileName>myapplet.jar</destFileName>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
如果您使用的是 Eclipse,则需要在 pluginManagement
中添加插件生命周期映射(如果您还没有)。确保目标copy
具有操作execute
。
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-dependency-plugin
</artifactId>
<versionRange>
[2.2,)
</versionRange>
<goals>
<goal>copy</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute/>
</action>
</pluginExecution>
...
关于java - 在 JBoss 上发布时通过 Maven 插件复制文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14220638/