简体   繁体   English

如何强制Eclipse使用Maven进行自动构建

[英]How to force Eclipse to use maven for automatic build

I am using Eclipse ,Spring,tomcat server,maven. 我正在使用Eclipse,Spring,tomcat服务器,maven。 I need to pass some parameters when i build the project with maven.Everything works fine when i do that using command line or when i right click on POM.xml and run it making run configuration changes in eclipse. 当我使用Maven构建项目时,我需要传递一些参数。当我使用命令行或右键单击POM.xml并运行它以使运行配置在Eclipse中更改时,一切工作正常。

But as soon as i start my tomcat it is not able to find the value i want to pass in the parameter and it gives an exception 但是,一旦我启动了tomcat,它就无法找到我想要传递给参数的值,并且给出了异常

: Could not open ServletContext resource [/WEB-INF/classes/properties/application-${spring.profiles.active}.properties] :无法打开ServletContext资源[/WEB-INF/classes/properties/application-${spring.profiles.active}.properties]

here ${spring.profiles.active} should be replaced the the argument value. 此处$ {spring.profiles.active}应该替换为参数值。

So eclipse is not using maven with argument to build and deploy on the server automatically. 因此,eclipse不会使用带有参数的maven自动在服务器上构建和部署。

Insert the required maven plugins (especially maven-eclipse-plugin ) in the pom.xml for compiling the code and use the command mvn eclipse:eclipse in the project's base directory. pom.xml插入所需的maven插件(尤其是maven-eclipse-plugin )以编译代码,并在项目的基本目录中使用命令mvn eclipse:eclipse This will do the required stuff to create a maven project in eclipse. 这将完成在Eclipse中创建Maven项目所需的工作。

This is a very complicated subject where many things can go wrong. 这是一个非常复杂的主题,其中很多事情都会出错。 You need to be very explicit of how you are running tomcat. 您需要非常明确地了解如何运行tomcat。 Are you using wtp? 您在使用wtp吗? WTP would be the panel that says "Servers". WTP将是显示“服务器”的面板。 Is this spring boot? 这是春季靴吗? Do have the m2eclipse wtp plugin installed (its very hidden and not easy to find)? 是否安装了m2eclipse wtp插件(它非常隐藏且不容易找到)?

One easier way to get this right is just use springs version of eclipse. 一种更简单的方法就是使用springs eclipse。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM