zoukankan      html  css  js  c++  java
  • maven 相关插件

    maven打包配置,到底要打包哪些文件,如何配置??使用如下插件:

        <build>
            <finalName>weatherAdminSys</finalName>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>2.1.1</version>
                    <configuration>
                        <webXml>webWEB-INFweb.xml</webXml>
                        <webResources>
                            <resource>  <!-- 重点看 -->
                                <directory>
                                    web/
                                </directory>
                            </resource>
                        </webResources>
                    </configuration>
                </plugin>
                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                        <source>1.7</source>
                        <target>1.7</target>
                        <encoding>UTF-8</encoding>
                    </configuration>
                </plugin>
            </plugins>
        </build>

    maven打包带依赖可执行的jar(注意需要指定main所在类), 执行 mvn clean assembly:assembly命令

    执行:java -jar http-client-netty-1.0-SNAPSHOT-jar-with-dependencies.jar

        <plugins>
                <plugin>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <version>2.2</version>
                    <configuration>
                        <archive>
                            <manifest>
                                <mainClass>com.pt.utils.HttpClientUtil</mainClass>
                            </manifest>
                        </archive>
                        <descriptorRefs>
                            <descriptorRef>
                                jar-with-dependencies
                            </descriptorRef>
                        </descriptorRefs>
                    </configuration>
                </plugin>
            </plugins>

     spring-boot 打包JAR

    <!--打包成可执行的jar-->
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                    <!--高版本要求JDK8-->
                    <version>1.3.5.RELEASE</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>repackage</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>

     java scala混合编译,加入scala编译插件

        <plugin>
                    <groupId>net.alchim31.maven</groupId>
                    <artifactId>scala-maven-plugin</artifactId>
                    <version>3.2.2</version>
                    <executions>
                        <execution>
                            <id>scala-compile-first</id>
                            <phase>process-resources</phase>
                            <goals>
                                <goal>add-source</goal>
                                <goal>compile</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>scala-test-compile</id>
                            <phase>process-test-resources</phase>
                            <goals>
                                <goal>testCompile</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>    

     或者:

    <plugin>
                    <groupId>org.scala-tools</groupId>
                    <artifactId>maven-scala-plugin</artifactId>
                    <version>2.15.2</version>
                    <executions>
                        <execution>
                            <id>scala-compile-first</id>
                            <phase>process-resources</phase>
                            <goals>
                                <goal>compile</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>scala-test-compile</id>
                            <phase>process-test-resources</phase>
                            <goals>
                                <goal>testCompile</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <jvmArgs>
                            <jvmArg>-Xms64m</jvmArg>
                            <jvmArg>-Xmx1024m</jvmArg>
                        </jvmArgs>
                        <useFsc>true</useFsc>
                        <once>true</once>
                    </configuration>
                </plugin>
    View Code

    输出依赖jar到lib文件:

          <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <version>3.0.2</version>
                    <executions>
                        <execution>
                            <id>copy-dependencies</id>
                            <phase>package</phase>
                            <goals>
                                <goal>copy-dependencies</goal>
                            </goals>
                            <configuration>
                                <outputDirectory>${project.build.directory}/lib</outputDirectory>
                                <overWriteReleases>false</overWriteReleases>
                                <overWriteSnapshots>false</overWriteSnapshots>
                                <overWriteIfNewer>true</overWriteIfNewer>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
  • 相关阅读:
    人生苦短,我用python-- Day18 正则+组件+django框架
    人生苦短,我用python-- Day17 jQuery讲解
    人生苦短,我用python-- Day16 JavaScript补充+Dom补充
    人生苦短,我用python-- Day15 css+js
    Centos 7 Yum安装Mysql
    人生苦短,我用python-- Day14之html
    人生苦短,我用python-- Day12
    人生苦短,我用python-- Day11
    Tomcat应用报redis超时的故事
    小康陪你学JAVA--------面向对象程序设计(绪)
  • 原文地址:https://www.cnblogs.com/tengpan-cn/p/6043187.html
Copyright © 2011-2022 走看看