Skip to content

Maven uses 'start-class' when the parent POM is being used and ignores 'spring-boot.run.main-class' #40145

Closed
@siddhsql

Description

@siddhsql

I wrote a spring application with multiple main classes. When I try to run it as follows:

mvn spring-boot:run \
 -Dspring-boot.run.profiles=profile2 \
 -Dspring-boot.run.main-class=com.example.demo.DemoApplication2

I get this error:

Execution default-cli of goal org.springframework.boot:spring-boot-maven-plugin:3.1.5:run failed: Unable to find a single main class from the following candidates [com.example.demo.DemoApplication2, com.example.demo.DemoApplication]

If I remove the following from my pom.xml:

<parent>	
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>3.1.5</version>
    <relativePath/> 
</parent>

then it works! seems like a bug.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions