一、第一种比较简单,用直接把jar包安装在maven库进去,但是只在windows上面测试可以,ubuntu或者其他操作系统,建议使用第二种。
首页需要本地安装maven环境,然后用cmd把 demo.jar 安装到Maven库里面
命令:mvn install:install-file -Dfile=(jar包的位置) -DgroupId=groupId(分组) -DartifactId=artifactId(jar名称) -Dversion=version(版本号) -Dpackaging=jar
例子:mvn install:install-file -Dfile=D:\pro\delta\delta-common-0.0.1.jar -DgroupId=com.usmart.ipems -DartifactId=delta-common -Dversion=0.0.1 -Dpackaging=jar
BUILD SUCCESS 说明成功了
然后需要把这个加入到pom.xml下面
然后就可以正常启动了。。。
二、把jar包直接引入到项目进去,但是需要打包的时候也加配置
把jar包放在resources下面或者你想放哪里都可以,但是pom引入的时候要注意
接下来看pom.xml
后面标蓝的这两段是要加的(另外注意给个版本号,不然打包也报错)
接下来就是打包环节了
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<includeSystemScope>true</includeSystemScope>
</configuration>
</plugin>
需要把这个写到pom.xml 里面,因为打包默认不打印system的包,不加此配置,本地可以运行,因为本地可以再lib下找到外部包,但是服务器上jar中是没有的。
然后现在进行启动和打jar包,都是没问题的
打开jar包,里面的第三方的jar也进去了