eclipse maven编译java项目,Eclipse的区别构建项目和Maven编译命令

Is Eclipse "Build Project" command same as the Maven command "mvn compile"? Do both basically do the same thing?

If Yes, then why do I need to do a "Build Project" in STS after running "mvn clean install" in order to run the application without any issues? Running "mvn clean install" should have already compiled the project. Shouldn't Refreshing the project in STS be enough to run it?

If No, then is Eclipse build different because the Java compiler implements the Java Language Specification to build the classes? But the following Apache Maven link says that the default compiler is javax.tools.JavaCompiler (By the way I am using Java 1.6).

解决方案

I think I may have found an answer to my question. Firstly I'd like to say that I do have the M2E (Maven plugin for Eclipse) installed in my STS. I spoke to a colleague of mine and he agreed that they are both the same thing (Build Project and the "mvn compile"). Refreshing the Project in STS after running a "mvn clean install" should be sufficient to run your Project. However there are times when he runs into exceptions during execution with just a Refresh. Only then does he perform a Refresh, "Build Project" and then Run. He says it's probably a bug that STS sometimes requires a Build.

With the M2Eclipse plugin you can run your "mvn clean install" command directly from your Eclipse in two ways:

1. Right click on your Maven Project> Run As> [Select your maven command]

2. Right click on your pom.xml in your Maven Project> Run As> [Select your maven command]

I still prefer running the maven commands through command line though. :)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值