maven设置编译jdk版本,以及maven打包

1,设置编译版本为jdk 1.8

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.5</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
                <encoding>UTF-8</encoding>
            </configuration>
        </plugin>
    </plugins>
</build>

2 maven排除依赖jar包中的子jar

<dependency>
    
<groupId>com.xx.xx</groupId>
    
<artifactId>xx</artifactId>
    
<version>${xx.version}</version>
    
<exclusions>
        
<exclusion>
            
<groupId>org.springframework</groupId>
           
 <artifactId>*</artifactId>
        
</exclusion>

</exclusions> </dependency>

3,将maven将java项目依赖包一起打入一个jar包内需要的配置

 <plugin>    
           <artifactId>maven-assembly-plugin</artifactId>    
                <configuration>    
                    <descriptorRefs>    
                        <descriptorRef>jar-with-dependencies</descriptorRef>    
                    </descriptorRefs>    
                    <archive>    
                        <manifest>    
                          <mainClass></mainClass>    
                        </manifest>    
                    </archive>    
                </configuration>    
                <executions>    
                    <execution>    
                        <id>make-assembly</id>    
                        <phase>package</phase>    
                        <goals>    
                            <goal>single</goal>    
                        </goals>    
                    </execution>    
             </executions>    
</plugin>   

打包的命令: 在项目的目录下的命令行输入:mvn clean package

posted @ 2018-01-28 23:23  2412cyy  阅读(15427)  评论(0编辑  收藏  举报