Python 官方文档:入门教程 => 点击学习
开门见山 项目运行的环境里面已经有该项目的所有代码依赖,所以项目的代码只要将自己的代码打入进去就能提交到环境中运行了。但是不好的地方就是项目运行环境里面有
项目运行的环境里面已经有该项目的所有代码依赖,所以项目的代码只要将自己的代码打入进去就能提交到环境中运行了。但是不好的地方就是项目运行环境里面有一个jar
包是pom
文件依赖其它项目的jar
包,当这个jar
包代码发生变更的时候,需要将环境中的该代码对应的jar
包进行替换,所以最后得到的项目jar
包中打入该项目的代码之后还需要打入其它项目的最新代码。
模板如下:
<build>
<plugins>
<plugin>
<groupId>org.apache.Maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<Goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
<configuration>
<artifactSet>
<includes>
<include>Mysql:mysql-connector-java</include>
<!--- <incldue>groupid:artifactId</include> ----->
<!--- <incldue>groupid:artifactId</include> ----->
<!--- <incldue>groupid:artifactId</include> ----->
</includes>
</artifactSet>
</configuration>
</plugin>
</plugins>
</build>
在进行maven
的package
之后,项目代码的target
代码中会发现除了打了项目代码之外,还有mysql
的connector
代码。
知识点扩展:
maven 将依赖包打入jar中
在 pom.xml 的 build 标签中加入如下配置:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<arcHive>
<manifest>
<!-- 此处指定main方法入口的class -->
<mainClass>com.xxx.Main</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
以上就是Maven如何打入依赖中指定的部分jar包的详细内容,更多关于Maven打入依赖jar包的资料请关注编程网其它相关文章!
--结束END--
本文标题: Maven如何打入依赖中指定的部分jar包
本文链接: https://www.lsjlt.com/news/129150.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0