Configuring Spring Roo for Java 7

When creating a Roo project with the “project” command, we have the option to specify the Java Version

$ roo
roo> project --topLevelPackage com.gordondickens.myproj --java 6 --projectName testapp

If we choose Java 7 with Roo 1.2.1, the code will not compile with AspectJ included.

Steps to change to Java 7:

  • Change the Java version to 1.7
  • Set the AspectJ version to 1.7.0.M1 or higher
  • Set the Maven AspectJ Plugin to 1.4 or higher
  • If using Hypersonic, change the version to 2.2.8 or higher
  • Change the Hibernate version to 4.1.2 or higher
  • (optional) Change the Hibernate Entity Manager to 4.1.2 or higher
<properties>
  <aspectj.version>1.7.0.M1</aspectj.version>
  <java.version>1.7</java.version>
  <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  <roo.version>1.2.1.RELEASE</roo.version>
  <slf4j.version>1.6.4</slf4j.version>
  <spring.version>3.1.1.RELEASE</spring.version>
</properties>
...
<dependency>
  <groupId>org.hsqldb</groupId>
  <artifactId>hsqldb</artifactId>
  <version>2.2.8</version>
</dependency>
<dependency>
  <groupId>org.hibernate</groupId>
  <artifactId>hibernate-core</artifactId>
  <version>4.1.2</version>
</dependency>
<dependency>
  <groupId>org.hibernate</groupId>
  <artifactId>hibernate-entitymanager</artifactId>
  <version>4.1.2</version>
  <exclusions>
    <exclusion>
      <groupId>cglib</groupId>
      <artifactId>cglib</artifactId>
    </exclusion>
    <exclusion>
      <groupId>dom4j</groupId>
      <artifactId>dom4j</artifactId>
    </exclusion>
  </exclusions>
</dependency>
...
<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>aspectj-maven-plugin</artifactId>
  <version>1.4</version>
  <dependencies>
    <dependency>
      <groupId>org.aspectj</groupId>
      <artifactId>aspectjrt</artifactId>
      <version>${aspectj.version}</version>
    </dependency>
    <dependency>
      <groupId>org.aspectj</groupId>
      <artifactId>aspectjtools</artifactId>
      <version>${aspectj.version}</version>
    </dependency>
  </dependencies>
  <executions>
    <execution>
      <goals>
        <goal>compile</goal>
        <goal>test-compile</goal>
      </goals>
    </execution>
  </executions>
  <configuration>
    <outxml>true</outxml>
    <aspectLibraries>
      <aspectLibrary>
        <groupId>org.springframework</groupId>
        <artifactId>spring-aspects</artifactId>
      </aspectLibrary>
    </aspectLibraries>
    <source>${java.version}</source>
    <target>${java.version}</target>
  </configuration>
</plugin>
...

About Gordon

Technology enthusiast primarily focused on Java and Open Source projects. Spring Certified Professional and Trainer. http://twitter.com/gdickens http://linkedin.com/in/gordondickens http://github.com/gordonad
This entry was posted in AOP, AspectJ, Java, Java 7, JDK7, Maven, Roo, Spring, Spring AOP, Spring Data, Spring MVC and tagged , , , , , , . Bookmark the permalink.

One Response to Configuring Spring Roo for Java 7

  1. Daniel Serodio says:

    Since Roo doesn’t support Java 7 features (ROO-3106), what is the advantage of Configuring Spring Roo for Java 7?

Leave a Reply

Your email address will not be published. Required fields are marked *


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>