【发布时间】:2018-07-10 08:39:57
【问题描述】:
我有一个多模块(模型和服务模块)的maven项目:
model
|_____ABCEntity.java
service
|_____pom.xml
<dependency>model</dependency>
<dependency>code-generation</dependency>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<configuration>
<mainClass>com.codegenerator.CodeGeneratorApplication</mainClass>
</configuration>
</plugin>
在“模型”模块中,我有一个类名 ABCEntity.java,在服务模块中,我想扫描 ABCEntity.java 并生成一些样板类。
“服务”模块对“模型”模块具有 Maven 依赖关系,并且对代码生成器模块(外部应用程序)有依赖关系。
当我在“服务”模块中运行“mvn exec:java”时,我得到了一些错误,即找不到 ABCEntity.java:
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:294)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalStateException: Failed to execute ApplicationRunner
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:770)
at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:757)
at org.springframework.boot.SpringApplication.afterRefresh(SpringApplication.java:747)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1162)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1151)
at codegenerator.CodeGeneratorApplication.main(CodeGeneratorApplication.java:26)
... 6 more
Caused by: java.lang.ClassNotFoundException: ABCEntity
谁能帮我解决这个问题?我不明白为什么找不到 ABCEntity,因为: 1)ABCEntity在同一个项目中,但在另一个模块中 2)我已经声明了对该模块的依赖。
【问题讨论】:
标签: java maven exec-maven-plugin