springboot引入第三方jar包放到项目目录中,添加web.xml

参考博客:https://www.cnblogs.com/mask-xiexie/p/16086612.html

https://zhuanlan.zhihu.com/p/587605618

1、在resources目录下新建lib文件夹,将jar包放到lib文件夹中

springboot引入第三方jar包放到项目目录中,添加web.xml_第1张图片

2、修改pom.xml文件


	com.lanren312
	lanren312
	system
	1.0
	${project.basedir}/src/main/resources/lib/javatest.jar

备注:
groupId、artifactId、version这三个随便写
scope=system表示此依赖是来自外部jar,而不是maven仓库。当scope设置为system时,systemPath属性才会生效,systemPath为一个物理文件路径,来指定依赖的jar其物理磁盘的位置。
${project.basedir}固定写法

现在运行项目没有问题,但是打包就会发现jar包下 \BOOT-INF\lib\ 目录下没有我们刚刚添加的包,看下面的步骤

3、打jar、war包

packaging、build对应改下

jar

	heroes
	
		
			lib
			/lib/
			
				${project.basedir}/src/main/resources/lib/
			
		
		
			src/main/resources
			
				**/*
			
		
	
	
		
			org.springframework.boot
			spring-boot-maven-plugin
			
				
					
						org.projectlombok
						lombok
					
				
			
		

		
















		
		
			org.springframework.boot
			spring-boot-maven-plugin
			
				true
			
		
	

打jar包,在 \BOOT-INF\lib\ 就会看到 lanren312-1.0.jar

打war包,在 \WEB-INF\lib\ 就会看到 javatest.jar

springboot引入第三方jar包放到项目目录中,添加web.xml_第2张图片
 

springboot引入第三方jar包放到项目目录中,添加web.xml_第3张图片

4、 添加web.xml

参考博客 :https://blank.blog.csdn.net/article/details/85337396

springboot引入第三方jar包放到项目目录中,添加web.xml_第4张图片

springboot引入第三方jar包放到项目目录中,添加web.xml_第5张图片 

springboot引入第三方jar包放到项目目录中,添加web.xml_第6张图片 

 

你可能感兴趣的:(java,springboot,spring,boot)