demo文档建议将打包pom写到 profile里面

<profiles>

  <profile>
    <id>build</id>
    <dependencyManagement>
      <dependencies>
       <!-- <dependency>
          <groupId>com.jfinal</groupId>
          <artifactId>jetty-server</artifactId>
          <version>2018.11</version>
          <scope>provided</scope>
        </dependency>-->
        <dependency>
          <groupId>org.slf4j</groupId>
          <artifactId>slf4j-nop</artifactId>
          <version>1.7.25</version>
          <!-- 打包前改成 provided,此处使用 compile 仅为支持 IDEA -->
          <scope>provided</scope>
        </dependency>
      </dependencies>
    </dependencyManagement>

    <build>
      <finalName>build-test</finalName>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.6.1</version>
          <configuration>
            <source>1.8</source>
            <target>1.8</target>
            <encoding>UTF-8</encoding>
            <!-- java8 保留参数名编译参数 -->
            <compilerArgument>-parameters</compilerArgument>
            <compilerArguments><verbose /></compilerArguments>
          </configuration>
        </plugin>

        <!--
            jar 包中的配置文件优先级高于 config 目录下的 "同名文件"
            因此,打包时需要排除掉 jar 包中来自 src/main/resources 目录的
            配置文件,否则部署时 config 目录中的同名配置文件不会生效
         -->
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-jar-plugin</artifactId>
          <version>2.6</version>
          <configuration>
            <excludes>
              <exclude>*.txt</exclude>
              <exclude>*.xml</exclude>
              <exclude>*.properties</exclude>
            </excludes>
          </configuration>
        </plugin>

        <!--
            使用 mvn clean package 打包
            更多配置可参考官司方文档:http://maven.apache.org/plugins/maven-assembly-plugin/single-mojo.html
         -->
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-assembly-plugin</artifactId>
          <version>3.1.0</version>
          <executions>
            <execution>
              <id>make-assembly</id>
              <phase>package</phase>
              <goals>
                <goal>single</goal>
              </goals>

              <configuration>
                <!-- 打包生成的文件名 -->
                <finalName>${project.artifactId}</finalName>
                <!-- jar 等压缩文件在被打包进入 zip、tar.gz 时是否压缩,设置为 false 可加快打包速度 -->
                <recompressZippedFiles>false</recompressZippedFiles>
                <!-- 打包生成的文件是否要追加 release.xml 中定义的 id 值 -->
                <appendAssemblyId>true</appendAssemblyId>
                <!-- 指向打包描述文件 package.xml -->
                <descriptors>
                  <descriptor>package.xml</descriptor>
                </descriptors>
                <!-- 打包结果输出的基础目录 -->
                <outputDirectory>${project.build.directory}/</outputDirectory>
              </configuration>
            </execution>
          </executions>
        </plugin>

      </plugins>

    </build>

  </profile>
</profiles>


评论区

JFinal

2018-12-17 23:45

原因是什么呢?

big_demo

2019-01-21 09:12

@JFinal 打包阶段不用手动去修改pom文件,provide

JFinal

2019-01-21 11:12

@big_demo 目前就是可以不用修改主 pom.xml 的

热门反馈

扫码入社