springboot 打包 jar 含 lib

---------------- pom.xml 安装插件 ------------------

<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.cmhk</groupId>
  <artifactId>cmhkHiveHelper</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>cmhkHiveHelper</name>
  <url>http://maven.apache.org</url>;

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <poi.version>4.1.2</poi.version>
  </properties>

  <parent>
     <groupId>org.springframework.boot</groupId>
     <artifactId>spring-boot-starter-parent</artifactId>
     <version>2.1.6.RELEASE</version>
  </parent>

  <dependencies>
    <dependency>
       <groupId>org.springframework.boot</groupId>
       <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
       <version>3.8.1</version>
       <scope>test</scope>
   </dependency>
   		<dependency>
			<groupId>org.apache.hive</groupId>
			<artifactId>hive-jdbc</artifactId>
			<version>2.1.1</version>
			<classifier>standalone</classifier>
			<exclusions>
				<exclusion>
					<groupId>org.slf4j</groupId>
					<artifactId>slf4j-log4j12</artifactId>
				</exclusion>
				<exclusion>
					<groupId>log4j</groupId>
					<artifactId>log4j</artifactId>
				</exclusion>
				 <exclusion>
                    <artifactId>log4j-over-slf4j</artifactId>
                    <groupId>org.slf4j</groupId>
                 </exclusion>
				 <exclusion>
                    <artifactId>log4j-over-slf4j</artifactId>
                    <groupId>org.slf4j</groupId>
                 </exclusion>
			</exclusions>
		</dependency>
		

		<dependency>
		    <groupId>org.apache.poi</groupId>
		    <artifactId>poi</artifactId>
		    <version>${poi.version}</version>
		</dependency>
		<dependency>
		    <groupId>org.apache.poi</groupId>
		    <artifactId>poi-ooxml</artifactId>
		    <version>${poi.version}</version>
		</dependency>
		<dependency>
		    <groupId>org.apache.poi</groupId>
		    <artifactId>poi-scratchpad</artifactId>
		    <version>${poi.version}</version>
		</dependency>
		<dependency>
		    <groupId>org.apache.poi</groupId>
		    <artifactId>poi-examples</artifactId>
		    <version>${poi.version}</version>
		</dependency>
		<dependency>
		    <groupId>org.apache.poi</groupId>
		    <artifactId>poi-excelant</artifactId>
		    <version>${poi.version}</version>
		</dependency>
		<dependency>
		    <groupId>org.apache.poi</groupId>
		    <artifactId>poi-ooxml-schemas</artifactId>
		    <version>${poi.version}</version>
		</dependency>
  </dependencies>
  
  
  <build>
	  <plugins>
	  	 <!-- lib 打包到target目录 -->
		  <plugin>
		  <groupId>org.apache.maven.plugins</groupId>
		  <artifactId>maven-jar-plugin</artifactId>
		  <configuration>
		    <archive>
		      <manifest>
		        <!-- 添加依赖jar路径 -->
		        <addClasspath>true</addClasspath>
		        <!-- 入口程序 -->
		        <mainClass>com.cmhk.cmhkHiveHelper.CmhkHiveHelperApplication</mainClass>
		        <classpathPrefix>lib/</classpathPrefix>
		      </manifest>
		    </archive>
		  </configuration>
		</plugin>
		
	  </plugins>
  </build>
  
</project>

------------- 用cmd 到项目目录中,通过命令把所需的依赖jar打包到 target 目录的 lib 目录中 ------------------
1、mvn clean install
2、mvn clean dependency:copy-dependencies -DoutputDirectory=target/lib package
3、刷新目录,看到生成的lib目录,把 lib目录和 jar包 两个 copy 到 服务器上,用命令运行即可,如:
/xxx/jdk1.8_LIN_X64/bin/java -jar /xxx/cmhkHiveHelper/cmhkHiveHelper-0.0.1-SNAPSHOT.jar

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值