I created a project with maven2 on eclipse. After I added the hibernate-annotations dependency, i was trying to create a class using hibernate annotations(@Entity, @Table...), but it was giving me this error :
Change project compliance and JRE to 1.5
I fixed it, but cannot understand why it requires this as long as my jdk is 1.6.
Thank in advance!
Check that the settings for the maven compiler plugin is set to 1.5 or 1.6 as well. If I'm not mistaken maven 2 defaults to 1.4.
Something like this:
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
While javamonkey79's solution is the standard way to do it, there is also a property-based solution, but it's not the one fgysin suggests:
<properties>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
</properties>
Reference (Maven compiler plugin):
<source>
parameter<target>
parameterBTW, the reason is that the maven compiler plugin builds a command line call to javac in which it specifies source and target version explicitly (overriding javac's default settings). And previous versions of the compiler plugin had their own defaults set to 1.3. However, starting from plugin version 2.3, 1.5 is the default source and target version.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With