Why do I need to change project 1.5 compliance?

I created a project with maven2 on eclipse. After I added the hibernate-annotations dependency, I tried to create the class using hibernate annotations (@Entity, @Table ...), but this gave me this error:

Change project and JRE matching to 1.5

I fixed it, but I can’t understand why it requires this while my jdk is 1.6.

Thanks in advance!

+7
java maven-2
source share
3 answers

Make sure the maven compiler plugin is set to 1.5 or 1.6. If I'm not mistaken, maven 2 defaults to 1.4.

Something like that:

<plugin> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.1</version> <configuration> <source>1.5</source> <target>1.5</target> </configuration> </plugin> 
+11
source share

Although javamonkey79's solution is the standard way to do this, there is also a property-based solution, but this is not one fgysin offers :

 <properties> <maven.compiler.source>1.6</maven.compiler.source> <maven.compiler.target>1.6</maven.compiler.target> </properties> 

Link (Maven compiler plugin):

By the way, the reason is that the maven compiler plugin builds a command line call in javac, in which it explicitly indicates the source and target version (overriding javac default settings). And previous versions of the compiler plugin had their own default values ​​of 1.3. However, starting with version 2.3 of the plugin, 1.5 is the default source and target version .

+9
source share

Add the following lines to the POM:

  <properties> <java.version>1.6</java.version> </properties> 

Edit: Ah, too bad, just saw that these are the usual properties ... It will not work.

-one
source share

All Articles