-
Notifications
You must be signed in to change notification settings - Fork 40.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Maven uses 'start-class' when the parent POM is being used and ignores 'spring-boot.run.main-class' #40145
Comments
Thanks for getting in touch. Unfortunately, you have not provided enough information for us to be able to help you. If you would like us to spend some time investigating, please provide a complete minimal sample that reproduces the problem. You can share it with us by pushing it to a separate repository on GitHub or by zipping it and attaching it to this issue. |
The correct flag is Minimal Reproducible Example
mkdir demo &&
cd demo &&
curl https://start.spring.io/starter.tgz -d type=maven-project | tar -xzvf -
rm src/main/java/com/example/demo/DemoApplication.java
cat > src/main/java/com/example/demo/DemoApplication1.java <<EOF && cat > src/main/java/com/example/demo/DemoApplication2.java <<EOF
package com.example.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class DemoApplication1 {
public static void main(String[] args) {
SpringApplication.run(DemoApplication1.class, args);
}
}
EOF
package com.example.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class DemoApplication2 {
public static void main(String[] args) {
SpringApplication.run(DemoApplication2.class, args);
}
}
EOF
./mvnw spring-boot:run
# Or: ./mvnw spring-boot:run -Dspring-boot.run.main-class=com.example.demo.DemoApplication1
# Or: ./mvnw spring-boot:run -Dspring-boot.run.main-class=com.example.demo.DemoApplication2
./mvnw spring-boot:run -Dstart-class=com.example.demo.DemoApplication1
# Or: ./mvnw spring-boot:run -Dstart-class=com.example.demo.DemoApplication2 |
attached MRE as zipped file If the correct flag is
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.4</version>
<relativePath/>
</parent> |
Upon closer inspection, you're right: you shouldn't have to resort to a JVM system property ( However, here's what Bael Dung has to say:
Hence, I stand corrected: this is a bug in my opinion. |
This is an interesting problem and I'm not sure how to best solve it. Our We'll need to discuss this some more to work out what we should do. |
This comment was marked as abuse.
This comment was marked as abuse.
This comment was marked as outdated.
This comment was marked as outdated.
If we add this in our parent: <properties>
<spring-boot.run.main-class>${start-class}</spring-boot.run.main-class>
</properties> and then change the config of the <plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<id>repackage</id>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>${spring-boot.run.main-class}</mainClass>
</configuration>
</plugin> then both |
The other plugins we configure with
I don't think any of those have |
I wrote a spring application with multiple main classes. When I try to run it as follows:
I get this error:
If I remove the following from my
pom.xml
:then it works! seems like a bug.
The text was updated successfully, but these errors were encountered: