无法使用maven-assembly-plugin设置类路径

D.R*_*.R. 11 java maven-2 classpath executable-jar pom.xml

我正在创建控制台应用程序 我想在jar文件conf夹中的文件外部配置文件,并希望将此文件夹注册为我的应用程序的类路径.

我运行mvn assembly:single命令,得到一个jar文件,但是当我尝试运行这个JAR时java -jar MyApplication.jar,它无法读取配置文件.

我有这个片段 pom.xml

<build>
    <finalName>MyApplication</finalName>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.1</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-eclipse-plugin</artifactId>
            <version>2.7</version>  
            <configuration>
                <projectNameTemplate>
                    [artifactId]-[version]
                </projectNameTemplate>
                <wtpmanifest>true</wtpmanifest>
                <wtpapplicationxml>true</wtpapplicationxml>
                <wtpversion>2.0</wtpversion>
                <manifest>
                    ${basedir}/src/main/resources/META-INF/MANIFEST.MF
                </manifest>
            </configuration>

        </plugin>

        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <configuration>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
                <appendAssemblyId>false</appendAssemblyId>
                <archive>
                    <manifest>
                        <mainClass>com.my.test.App</mainClass>
                    </manifest>
                    <manifestEntries>
                        <Class-Path>.conf/</Class-Path>
                    </manifestEntries>
                </archive>
            </configuration>
        </plugin>
    </plugins>
</build>
Run Code Online (Sandbox Code Playgroud)

D.R*_*.R. 10

这是我的错,我不得不放

<Class-Path>./conf/</Class-Path>
Run Code Online (Sandbox Code Playgroud)

并不是

<Class-Path>.conf/</Class-Path>
Run Code Online (Sandbox Code Playgroud)