我有一个使用AspectJ和Spring Roo的应用程序。我没有这些技术的经验。在Maven的建筑中(3.3.9 )我在控制台中遇到错误:
im@im:~/projects/maintenance$ mvn clean install
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building maintenance 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ maintenance ---
[INFO]
[INFO] --- aspectj-maven-plugin:1.2:compile (default) @ maintenance ---
[ERROR] The method getId() is undefined for the type Employee
并且错误是合理的,因为在getId()
类中我确实没有Employee
方法,但是我有以下注释:
import ...
@RooJavaBean
@RooToString
@RooJpaActiveRecord(persistenceUnit = "entityManagerFactoryMaintenance", identifierField = "id", identifierColumn = "EMPLOYEE_ID", versionColumn = "", versionField = "", finders = { "findEmployeesByHireDateIsNull" }, mergeMethod = "", persistMethod = "", removeMethod = "")
@JsonSerialize(include = Inclusion.NON_NULL)
@Table(name = "EMPLOYEES"/*, schema = Constants.ORACLE_MAINTENANCE_SCHEMA*/)
public class Employee {..}
我猜这是AspectJ中某个地方的问题。这是我的pom.xml
部分,其中包含AspectJ:
<properties>
<aspectj.version>1.8.1</aspectj.version>
<java.version>8</java.version>
<roo.version>1.3.1.RC1</roo.version>
<hibernate.version>4.0.1.Final</hibernate.version>
<spring.version>4.0.9.RELEASE</spring.version>
...
</properties>
...
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>${aspectj.version}</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>${aspectj.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
<version>${spring.version}</version>
</dependency>
...
</dependencies>
...
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.2</version>
<!-- NB: do not use 1.3 or 1.3.x due to MASPECTJ-90 and do not use 1.4
due to declare parents issue -->
<dependencies>
<!-- NB: You must use Maven 2.0.9 or above or these are ignored (see
MNG-2972) -->
<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>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.7</version>
<!-- Note 2.8 does not work with AspectJ aspect path -->
<configuration>
<downloadSources>true</downloadSources>
<downloadJavadocs>false</downloadJavadocs>
<wtpversion>2.0</wtpversion>
<additionalBuildcommands>
<buildCommand>
<name>org.eclipse.ajdt.core.ajbuilder</name>
<arguments>
<aspectPath>org.springframework.aspects</aspectPath>
</arguments>
</buildCommand>
<buildCommand>
<name>org.springframework.ide.eclipse.core.springbuilder</name>
</buildCommand>
</additionalBuildcommands>
<additionalProjectnatures>
<projectnature>org.eclipse.ajdt.ui.ajnature</projectnature>
<projectnature>com.springsource.sts.roo.core.nature</projectnature>
<projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>
</additionalProjectnatures>
</configuration>
</plugin>
...
</plugins>
</build>
我也不知道IDE。我在Ubuntu上使用IntelliJ IDEA 2019.1.2(Ultimate Edition)。使用Eclipse如此重要吗?
我该如何构建应用程序?