Maven Tips

Here are some tips for Maven Java Projects in Eclipse.

#1 If you pom.xml is missing maven-compiler-plugin, Eclipse (when you do Maven > Update Project), defaults the compiler level for the project to 1.5.

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>

Now, it gets even more tricky… if your project has defined features that are from Java 1.6, 1.7 or 1.8

#2 if you your web.xml defines a version not compatible with a project facet you depend on, you get a lot of problems/errors

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"/>

Convert the web.xml to 3.1, and compatibility should now be fixed

<web-app id="WebApp_ID" version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">

I found this stackoverflow entry helpful and this one.

#3 Update > Maven Project overwrites manual changes to #1/#2.

I found this stackoverflow entry helpful.

#4 Make sure you don’t have two web.xml files… the convert dynamic web project to maven project does some funky stuff.

Leave a Reply

Your email address will not be published. Required fields are marked *