Tag Archive: Eclipse


When generating a maven project in Eclipse, Eclipse uses the m2eclipse plugin to generate the project. If you use one of the quickstart archetypes (maven-archetype-quickstart), m2eclipse refers to the configuration of the maven-compiler-plugin, which uses the ridiculous default setting of Java 1.5.
If you don’t want to manually correct your project, by changing the pom.xml and update your project, every time you create a new project, you can also change the maven-compiler-plugin default setting:

  • Go to you .m2 folder (in Windows C:\Users\\.m2)
  • From the .m2 folder, go to repository\org\apache\maven\plugins\maven-compiler-plugin\3.1 (this folder will be available, if you created a new maven project from Eclipse at least once).
  • Open maven-compiler-plugin-3.1.jar with a zip program.
  • Goto META-INF/maven and open the plugin.xml
  • The following lines are twice in the XML document:

    <source implementation="java.lang.String" default-value="1.5">${maven.compiler.source}</source>
    <target implementation="java.lang.String" default-value="1.5">${maven.compiler.target}</target>


  • Change the default-value attribute to 1.8:

    <source implementation="java.lang.String" default-value="1.8">${maven.compiler.source}</source>
    <target implementation="java.lang.String" default-value="1.8">${maven.compiler.target}</target>


  • Save the document and make sure that the plugin.xml is updated in the zip file.

From now on Eclipse creates Maven projects with Java version 1.8.

Sample Maven File For Eclipse

When creating a maven project in Eclipse, the archetypes use ridiculously outdated default parameters, such as Java 1.5 or Dynamic Web Module 2.3.

When using the webapp archetype, a few of the default settings can be corrected, using the following pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>de.test</groupId>
    <artifactId>MyService</artifactId>
    <packaging>war</packaging>
    <version>0.0.1-SNAPSHOT</version>
    <name>MyService Maven Webapp</name>
    <url>http://maven.apache.org</url>
  
    <dependencies>
        <!-- JUnit Files -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.1.0</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
    <build>
        <finalName>MyService</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.6</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.3</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

Next replace your web.xml with the following web.xml:

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

</web-app>

Next switch to the Navigator View, open org.eclipse.wst.common.project.facet.core.xml from your .settings folder and replace

<installed facet="jst.web" version="2.3"/>

with

<installed facet="jst.web" version="3.1"/>

Now right click your project and click on Maven -> Update Project.

Go to your Navigator again and

  • create the folder java under src/main
  • create the folder java under src/test

This should fix most of the problems and enable you to use Maven in Eclipse.

JVM mit mehr Speicher starten

Beim Start der JVM kann der Parameter -Xmx512M angeben werden, um den maximalen Heapspeicher auf 512 MB zu erhöhen. Entsprechend erhöht das Argument -Xms512M den anfänglichen Heap Speicher auf 512 MB.

Durch die Umgebungsvariable JAVA_OPTS können Argumente an die JVM, die den Tomcat startet, übergeben werden.
Beispiel:
set JAVA_OPTS=-Xmx512M -Xms512M

Beim Start von Eclipse können JVM Argumente über den Schalter -vmargs übergeben werden.
Beispiel:
eclipse -vmargs -Xmx512M