Here are all the steps I followed firstly to change Java version and then fixing the above-mentioned issue:
1. To build an AEM project with Java8 as a runtime environment, the following configuration is required in pom.xml. The Compiler Plugin is added to the parent POM, it is used to compile the sources of your project.
1. To build an AEM project with Java8 as a runtime environment, the following configuration is required in pom.xml. The Compiler Plugin is added to the parent POM, it is used to compile the sources of your project.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<inherited>true</inherited>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
The default source and target setting is 1.5. If you want to change it to work with Java 8, you should set the source and target to 1.8.
2. If you want to use scr annotations in your project, you have to use a maven-scr-plugin. And its version >= 1.17.0 for Java8
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-scr-plugin</artifactId>
<version>1.17.0</version>
</plugin>
3. For SCR annotations, following dependency should be added in the project with the version >= 1.9.8 for Java8
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.scr.annotations</artifactId>
<version>1.9.8</version>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<inherited>true</inherited>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
The default source and target setting is 1.5. If you want to change it to work with Java 8, you should set the source and target to 1.8.
2. If you want to use scr annotations in your project, you have to use a maven-scr-plugin. And its version >= 1.17.0 for Java8
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-scr-plugin</artifactId>
<version>1.17.0</version>
</plugin>
3. For SCR annotations, following dependency should be added in the project with the version >= 1.9.8 for Java8
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.scr.annotations</artifactId>
<version>1.9.8</version>
No comments:
Post a Comment
If you have any doubts or questions, please let us know.