Gordon Dickens is an instructor, mentor & consultant. Gordon is currently architecting and teaching several official SpringSource courses and actively tweets about open source technology at http://twitter.com/gdickens. Gordon is active within the Spring Framework community focussed on: Spring training, Spring Roo, Spring Integration, Spring Batch and Eclipse Virgo OSGi projects. Gordon is a DZone MVB and is not an employee of DZone and has posted 39 posts at DZone. You can read more from them at their website. View Full User Profile

Configuring Spring Roo for Java 7

04.08.2012
| 4362 views |
  • submit to reddit

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 

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>
...

 

 

Published at DZone with permission of Gordon Dickens, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)