我想将startup MBEAN
文件(startup-client-service.xml)
从EJB
> META-INF
移至EAR
> META-INF
文件夹。我尝试使用maven-resources-plugin
插件,但只是将文件从EJB
> META-INF
复制到Target
文件夹中的ear
。但在内置版ear
中,startup-client-service.xml
META-INF
文件
如何将我的启动文件移动到META-INF到耳朵> META-INF?
这是耳朵的pom文件。
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.testapp</groupId>
<artifactId>my-client-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<name>Test app EAR</name>
<artifactId>my-client-ear</artifactId>
<packaging>ear</packaging>
<dependencies>
<dependency>
<groupId>com.testapp</groupId>
<artifactId>my-client-ejb</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>ejb</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.8</version>
<configuration>
<defaultLibBundleDir>lib</defaultLibBundleDir>
<modules>
</modules>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>META-INF</outputDirectory>
<resources>
<resource>
<directory>${project.parent.basedir}/ejb/src/main/resources/META-INF</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<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-ear-plugin
</artifactId>
<versionRange>
[2.8,)
</versionRange>
<goals>
<goal>
generate-application-xml
</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<profiles>
<profile>
<id>copy_bundle</id>
<properties>
<install.dir>${jboss.dir}\server\default\deploy</install.dir>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>Copying bundle to destination folder</id>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<copy
file="${project.build.directory}/${project.build.finalName}.${project.packaging}"
overwrite="true" todir="${install.dir}" />
</tasks>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
以下是项目工作区屏幕抓取
答案 0 :(得分:23)
正确的方法是将文件添加到src/main/application
而不是src/main/resources
。
您还可以指定其他earSourceDirectory配置。
答案 1 :(得分:1)
我建议你在prepare-package阶段使用Maven资源插件将文件复制到$ {build.directory} / $ {project.artifactId} - $ {project.version} / META-INF文件夹,这是压缩最终EAR的文件夹。阶段准备包就在EAR被压缩之前。
答案 2 :(得分:0)
这是一个完整的例子
<build>
<plugins>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-resources</id>
<phase>process-resources</phase>
<goals>
<goal>resources</goal>
</goals>
<configuration>
<outputDirectory>
${basedir}/target/${project.artifactId}-${project.version}
</outputDirectory>
<resources>
<resource>
<directory>${project.parent.basedir}/ejb/src/main/resources/META-INF</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
...
答案 3 :(得分:0)
基于mekondelta的建议,我已经成功地使用 maven-assembly-plugin 将文件添加到EAR META-INF中。 就我而言,这些文件是**。properties *,保存在我项目的“ src / main / resources / META-INF”下。
在我的POM中,XML具有以下构建配置:
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.10.1</version>
<configuration>
<version>5</version>
<defaultLibBundleDir>lib/</defaultLibBundleDir>
<skinnyWars>true</skinnyWars>
<jboss>
<version>5</version>
<loader-repository>mcsa:loader=my-application</loader-repository>
<loader-repository-config>java2ParentDelegation=false</loader-repository-config>
<data-sources>
<data-source>my-ds.xml</data-source>
</data-sources>
</jboss>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>make-metainf</id>
<!--<phase>initialize</phase>-->
<phase>generate-resources</phase>
<configuration>
<!--<finalName>.</finalName>-->
<finalName>${project.artifactId}-${project.version}</finalName>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>src/main/resources/metainf-assembly.xml</descriptor>
</descriptors>
</configuration>
<goals>
<goal>directory</goal>
</goals>
</execution>
</executions>
</plugin>
</build>
metainf-assembly.xml 如下:
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2
http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>meta-data</id>
<includeBaseDirectory>false</includeBaseDirectory>
<formats>
<format>dir</format>
</formats>
<fileSets>
<fileSet>
<directory>${project.build.directory}/filtered-resources/META-INF/</directory>
<outputDirectory>META-INF</outputDirectory>
<includes>
<include>*.properties</include>
</includes>
</fileSet>
</fileSets>
答案 4 :(得分:0)
我设法使用maven-resources-plugin
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/${env.APPLICATION_NAME}/META-INF/</outputDirectory>
<resources>
<resource>
<directory>src/main/application/</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
注意:资源必须位于src \ main \ application \ META-INF \ weblogic-application.xml
答案 5 :(得分:0)
最简单的方法,至少在不是EAR的情况下(没有尝试过),只是在./src/main/resources中简单地包含一个带有所需文件的META-INF目录。 当然,这不能解决您的问题,因为文件生成到其他位置。