Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven won't compile Java annotations?

I'm having trouble getting maven to compile a project that uses Java annotations. I get the following error message:

annotations are not supported in -source 1.3 (use -source 5 or higher to enable annotations)
@PostConstruct

In my POM I have the following compiler plugin so for a start where is it getting -source 1.3 from?

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

I suspect I am probably missing something very simple to get this working but googling the error doesn't bring up anything helpful

Any help would be greatly appreciated

like image 769
RobV Avatar asked Nov 28 '25 22:11

RobV


1 Answers

Make sure that your <plugin> element is inside <build> section and not only in <pluginManagement> or <reporting> sections.

like image 168
Juha Syrjälä Avatar answered Dec 01 '25 13:12

Juha Syrjälä



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!