【发布时间】:2020-12-24 09:59:24
【问题描述】:
我有一个使用 Micronaut 的简单 maven 项目。我正在尝试创建一个新模块并制作典型的“WelcomeController”,并将该模块与父 pom 进行通信。
我可以通过mvn exec:exec 命令行运行它,但使用 IDE (IntelliJ IDEA) 运行它对我不起作用。我收到以下错误:
Error: Could not find or load main class com.example.Application
Caused by: java.lang.ClassNotFoundException: com.example.Application
儿童 pom:
<parent>
<groupId>com.example.reports</groupId>
<artifactId>tnt-assignment-back</artifactId>
<version>0.1</version>
</parent>
<artifactId>tnt-rest</artifactId>
<description>Rest module for tnt-assignment</description>
<properties>
<exec.mainClass>com.example.reports.Application</exec.mainClass>
</properties>
父 pom:
<parent>
<groupId>io.micronaut</groupId>
<artifactId>micronaut-parent</artifactId>
<version>2.2.1</version>
</parent>
<groupId>com.example.reports</groupId>
<artifactId>tnt-assignment-back</artifactId>
<version>0.1</version>
<packaging>pom</packaging>
<modules>
<module>tnt-rest</module>
</modules>
有什么想法吗?我已经尝试了很多东西,但仍然不去。谢谢。
【问题讨论】:
-
您在 IDE 中使用什么运行配置?什么是 Maven exec 插件配置?
-
java.lang.ClassNotFoundException: com.example.Application- 在运行项目之前,请确保在 IDE 中 build 项目。 -
如果 mvn exec:exec 不起作用,请尝试 mvn exec:java 命令。更多信息请参考stackoverflow.com/questions/9846046/…
标签: maven kotlin intellij-idea micronaut