0

I have a simple maven project using Micronaut. I'm trying to create a new module and make the typical 'WelcomeController', and communicate that module with the parent pom.

I can run it command-line via mvn exec:exec but running it with the IDE (IntelliJ IDEA) doesn't work for me. I got the following error:

Error: Could not find or load main class com.example.Application
Caused by: java.lang.ClassNotFoundException: com.example.Application

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

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

Any ideas? I've tried many things but still don't go. Thanks.

7Bliz
  • 33
  • 1
  • 6
  • What run configuration do you use in IDE? What is the Maven exec plugin configuration? – Andrey Dec 24 '20 at 10:42
  • 1
    `java.lang.ClassNotFoundException: com.example.Application` - make sure you [build](https://www.jetbrains.com/help/idea/compiling-applications.html#compile_module) the project in IDE before running it. – Andrey Dec 24 '20 at 10:43
  • If mvn exec:exec not working, try mvn exec:java command. For more information refer https://stackoverflow.com/questions/9846046/run-main-class-of-maven-project – P.Sanjay Dec 24 '20 at 13:08

1 Answers1

0

It looks like you are trying to run com.example.Application from the IDE and maven is configured to run com.example.reports.Application.

Jeff Scott Brown
  • 26,804
  • 2
  • 30
  • 47