maven打本地可执行jar包

maven打本地可执行jar包。

将maven项目打成jar包,并且导出Lib,配置不打在jar包中,需要以下步骤:
1. mvn dependency:copy插件导出依赖包到lib。并排除特定data配置文件。
2. maven的resources插件将指定目录copy到jar外的conf。
3. 修改MANIFEST引入class-path和Main运行类。
4. mvn clean install将代码打成jar包。
5. 复制A.jar,lib,conf目录到服务器。
6. 通过nohup java -jar A.jar >nohup.out运行。日志在nohup.out中。

pom.xml配置


<plugin>
    <groupId>org.apache.maven.pluginsgroupId>
    <artifactId>maven-jar-pluginartifactId>
    <version>2.2version>
    <configuration>
        <archive>
            <manifestEntries>
                <Class-Path>.Class-Path>
            manifestEntries>
            <manifest>
                <mainClass>com.jdjr.test.container.MainmainClass>
                <addClasspath>trueaddClasspath>
                <classpathPrefix>lib/classpathPrefix>
            manifest>
        archive>
        <classesDirectory>
        classesDirectory>
        <excludes>
            <exclude>jsfresult/exclude>
        excludes>
    configuration>
plugin>

<plugin>
    <groupId>org.apache.maven.pluginsgroupId>
    <artifactId>maven-dependency-pluginartifactId>
    <executions>
        <execution>
            <id>copyid>
            <phase>packagephase>
            <goals>
                <goal>copy-dependenciesgoal>
            goals>
            <configuration>
                <outputDirectory>./target/liboutputDirectory>
            configuration>
        execution>
    executions>
plugin>

<plugin>
    <artifactId>maven-resources-pluginartifactId>
    <executions>
        <execution>
            <id>copy-resourcesid>
            <phase>validatephase>
            <goals>
                <goal>copy-resourcesgoal>
            goals>
            <configuration>
                <outputDirectory>${project.build.directory}/conf/jsfresultoutputDirectory>
                <resources>
                    <resource>
                        <directory>src/main/resources/jsfresultdirectory>
                        <filtering>truefiltering>
                    resource>
                resources>
            configuration>

        execution>
    executions>
plugin>

你可能感兴趣的:(____自动化测试)