0

我正在尝试创建一个可执行 jar 及其所有依赖项以及 spring 的配置 xml 文件。

这是 pom.xml 中 maven-assembly-plugin 的定义:

<plugin>
    <artifactId>maven-assembly-plugin</artifactId>
    <configuration>
        <archive>
            <manifest>
                <mainClass>service.coucou.Main</mainClass>
            </manifest>
        </archive>
        <descriptorRefs>
            <descriptorRef>jar-with-dependencies</descriptorRef>
        </descriptorRefs>
        <descriptors>
                     <descriptor>assembly.xml</descriptor>
                 </descriptors>
    </configuration>
</plugin>

这是程序集.xml:

<?xml version="1.0" encoding="UTF-8"?>
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
    <id>jar-with-dependencies</id>
    <formats>
        <format>jar</format>
    </formats>
    <includeBaseDirectory>false</includeBaseDirectory>
    <dependencySets>
        <dependencySet>
            <outputDirectory>/</outputDirectory>
            <useProjectArtifact>true</useProjectArtifact>
            <unpack>true</unpack>
            <scope>runtime</scope>
        </dependencySet>
    </dependencySets>
    <fileSets>
        <fileSet>
            <includes>
                <include>/src/main/resources/cxf.xml</include>
            </includes>
        </fileSet>
    </fileSets>
</assembly>

我正在尝试/src/main/resources/cxf.xml在创建的 jar 中包含文件。但它不包括xml。我怎样才能将它包含在 jar 中?

4

1 回答 1

0

替换为<fileSets/>

<fileSet>
  <directory>${basedir}/src/main/resources</directory>
  <includes>
    <include>cxf.xml</include>
  </includes>
</fileSet>
于 2013-02-14T14:05:05.860 回答