码迷,mamicode.com
首页 > 编程语言 > 详细

maven 打包 jar 注意事项

时间:2020-09-21 12:03:05      阅读:48      评论:0      收藏:0      [点我收藏+]

标签:插件   pen   java   art   mode   manifest   color   需要   pre   

一、IDEA中

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>com.familyxiao</groupId>
	<artifactId>GetGoodWeb</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<name>GetGoodWeb</name>
	<packaging>jar</packaging>
	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>1.5.9.RELEASE</version>
		<relativePath/>
	</parent>
	<dependencies>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>
		
		<!-- mybatis依赖 -->
		<dependency>
		    <groupId>org.mybatis.spring.boot</groupId>
		    <artifactId>mybatis-spring-boot-starter</artifactId>
		    <version>1.3.1</version>
		</dependency>
		<!-- 引入thymelaf 则不需要引入web依赖,若不需要thymelaf则需要添加spring-boot-starter-web -->
		<dependency>
		    <groupId>org.springframework.boot</groupId>
		    <artifactId>spring-boot-starter-thymeleaf</artifactId>
		</dependency>
		
		<dependency>
		    <groupId>org.springframework.boot</groupId>
		    <artifactId>spring-boot-starter-json</artifactId>
		    <version>2.2.2.RELEASE</version>
		</dependency>
		
		<dependency>
            <groupId>net.sf.json-lib</groupId>
            <artifactId>json-lib</artifactId>
            <version>2.2.3</version>
            <classifier>jdk15</classifier>
        </dependency>

		<!-- mysql依赖 -->
	    <dependency>
	        <groupId>mysql</groupId>
	        <artifactId>mysql-connector-java</artifactId>
	    </dependency>
	    
	     <dependency>
	      <groupId>org.springframework.boot</groupId>
	      <artifactId>spring-boot-starter-test</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-tomcat</artifactId>
<!--			<scope>provided</scope>-->
			<!-- provided 表明该包只在编译和测试的时候使用,去除默认的tomcat -->
			<!--<scope>provided</scope>-->
			<version>1.5.2.RELEASE</version>
			<scope>compile</scope>
		</dependency>
<!--		<dependency>-->
<!--			<groupId>javax.servlet</groupId>-->
<!--			<artifactId>javax.servlet-api</artifactId>-->
<!--			<version>3.1.0</version>-->
<!--		</dependency>-->
	</dependencies>
	<build>
	<plugins>
	<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>2.3.2</version>
				<configuration>
					<source>1.8</source>
					<target>1.8</target>
					<encoding>UTF-8</encoding>
				</configuration>
			</plugin>
		<plugin>
			<groupId>org.apache.maven.plugins</groupId>
			<artifactId>maven-jar-plugin</artifactId>
			<configuration>
				<archive>
					<manifest>
						<addClasspath>true</addClasspath>
						<useUniqueVersions>false</useUniqueVersions>
						<classpathPrefix>lib/</classpathPrefix>
						<mainClass>com.familyxiao.Application</mainClass>
					</manifest>
				</archive>
			</configuration>
		</plugin>
		<!-- 要使生成的jar可运行,需要加入此插件 -->
<!--		<plugin>-->
<!--			<groupId>org.springframework.boot</groupId>-->
<!--			<artifactId>spring-boot-maven-plugin</artifactId>-->
<!--		</plugin>-->
		<plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <version>2.0.1.RELEASE</version>
            <executions>
                <execution>
                    <goals>
                        <goal>repackage</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
	</plugins>
</build>
</project>

  

参见:https://blog.csdn.net/u011712163/article/details/89705295

 

maven 打包 jar 注意事项

标签:插件   pen   java   art   mode   manifest   color   需要   pre   

原文地址:https://www.cnblogs.com/xiaoruilin/p/13694656.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!