1

I am using Eclipse ,Spring,tomcat server,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.

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

: Could not open ServletContext resource [/WEB-INF/classes/properties/application-${spring.profiles.active}.properties]

here ${spring.profiles.active} should be replaced the the argument value.

So eclipse is not using maven with argument to build and deploy on the server automatically.

Gaurav
  • 91
  • 6
  • Have a look on this : http://stackoverflow.com/questions/11874017/controlling-a-project-with-maven-and-spring-how-to-set-spring-config-file-using – Tobi Jul 10 '15 at 09:28
  • Hi, My question is that I am able to get the argument that i am passing from maven and every this is fine if i deploy the jar on my tomcat by manually putting it into webapps folder. but when i use the tomcat that i haved added in eclipse and eclipse is building the war for me then i am not able to get the maven arguments.So, is there some way to force eclipse to use the maven configuration to build the war. – Gaurav Jul 10 '15 at 09:35

2 Answers2

0

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. This will do the required stuff to create a maven project in eclipse.

Codi
  • 511
  • 3
  • 19
  • i already have the below entry in my POm org.apache.maven.plugins maven-eclipse-plugin 2.8 true true 2.0 tried using mvn eclipse:eclipse in the bse DIR but still the same issue. The variable is not replaced with the value. – Gaurav Jul 10 '15 at 09:45
0

This is a very complicated subject where many things can go wrong. You need to be very explicit of how you are running tomcat. Are you using wtp? WTP would be the panel that says "Servers". Is this spring boot? Do have the m2eclipse wtp plugin installed (its very hidden and not easy to find)?

One easier way to get this right is just use springs version of eclipse.

Adam Gent
  • 47,843
  • 23
  • 153
  • 203