maven中如何打包源代码

maven中如何打包源代码,第1张

1、The source plugin can be used to create a jar file of the project sources from the command line or by binding the goal to the project's build lifecycle. To generate the jar from the command line, use the following command:运行后会在target目录中找到生成的源文件jar包。2、在pom.xml中添加:<build<plugins<plugin<artifactIdmaven-source-plugin</artifactId<version2.1</version<configuration<attachtrue</attach</configuration<executions<execution<phasecompile</phase<goals<goaljar</goal</goals</execution</executions</plugins</build配置中指定了phase为compile,意思是在生命周期compile的时候就将源文件打包,即只要执行的mvn命令包括compile这一阶段,就会将源代码打包。同样,phase还可以指定为package、install等等。

maven 编译命令

从别处拷贝来的maven项目,有时候会出现不能debug关联的情况,即按住ctrl键后不能跳转到相应的类或方法,这是需要eclipse环境生成 Eclipse 项目文件的。

可以在cmd命令窗口下进入到maven项目包含pom.xml文件的目录下,运行 mvn eclipse:eclipse 命令即可,如果还不行,可使用mvn compile :编译源代码 命令。

--------------------------------------------------------------------------------------------------------------------------------

下面是一些maven的常用命令:

Maven2 的运行命令为 : mvn ,

常用命令为 :

mvn archetype:create :创建 Maven 项目

mvn compile :编译源代码

mvn test-compile :编译测试代码

mvn test : 运行应用程序中的单元测试

mvn site : 生成项目相关信息的网站

mvn clean :清除目标目录中的生成结果

mvn package : 依据项目生成 jar 文件

mvn install :在本地 Repository 中安装 jar

mvn eclipse:eclipse :生成 Eclipse 项目文件

生成项目

建一个 JAVA 项目 : mvn archetype:create -DgroupId=com.demo -DartifactId=App

建一个 web 项目 : mvn archetype:create -DgroupId=com.demo -DartifactId=web-app -DarchetypeArtifactId=maven-archetype-webapp

生成 Eclipse 项目

普通 Eclipse 项目执行 : mvn eclipse:eclipse

Eclipse WTP 项目执行 : mvn eclipse:eclipse –Dwtpversion=1.0

更详细的,自己百度搜索 maven 编译,学习一下吧

用IDEA克隆项目,再把maven与IDEA整合,如图所示点这个:

再点绿色三角,就可以打包。

这项目真大,等我下好直接把jar包发给你。


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/yw/11775663.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-18
下一篇2023-05-18

发表评论

登录后才能评论

评论列表(0条)

    保存