score:59

Accepted answer

just for someone who faced with similar problem. i added spring-boot-maven-plugin in parent pom in section pluginmanagement section like this:

 <build>
    <pluginmanagement>
        <plugins>
            <plugin>
                <groupid>org.springframework.boot</groupid>
                <artifactid>spring-boot-maven-plugin</artifactid>
            </plugin>
        </plugins>
    </pluginmanagement>
</build>

then i added the plugin only in the modules using it (in plugin section).the project has been successfully built after that.

score:-1

i also had same issue, and solved by adding application class as

@springbootapplication
public class application {

    public static void main(string[] args) {
        springapplication.run(application.class, args);
    }
}

i missed adding application start point during configuration of project.

score:-1

there are 2 ways to solve the issue:

  1. create main class:
public class main {public static void main(string[] args){}}
  1. remove plugin from pom.xml:
<plugin>
     <groupid>org.springframework.boot</groupid>
     <artifactid>spring-boot-maven-plugin</artifactid>
</plugin>

score:0

if you manually build your sprint boot project by using maven then make sure your project has a class like " class application extends springbootservletinitializer " with main method in that.

score:0

in my case, i had missed bellow tag in progect pom:

<packaging>jar</packaging>

or

<packaging>war</packaging>

so, i added and it worked fine.

score:0

in my case, i had a kotlin project but the src dir was named java instead of kotlin by the ide. refactoring the name fixed the issue.

score:0

under

<artifactid></artifactid>

tag write this property

<properties>
<spring-boot.repackage.skip>true</spring-boot.repackage.skip>
</properties>

it is helped me

score:1

in my case i had to add the "sourcedirectory" and my pom.xml changed from:

...

<build>
    <plugins>
        <plugin>
            <groupid>org.springframework.boot</groupid>
            <artifactid>spring-boot-maven-plugin</artifactid>
        </plugin>
    </plugins>
</build>

...

to

...

<build>
    <sourcedirectory>src</sourcedirectory>
    <plugins>
        <plugin>
            <groupid>org.springframework.boot</groupid>
            <artifactid>spring-boot-maven-plugin</artifactid>
        </plugin>
    </plugins>
</build>

...

score:1

in my case, i had a code source file named java even though i was explicitly using kotlin:

<sourcedirectory>${project.basedir}/src/main/kotlin</sourcedirectory>
<testsourcedirectory>${project.basedir}/src/test/kotlin</testsourcedirectory>

score:1

with maven you can tell which is the main class by:

<build>
  <plugins>
    <plugin>
      <configuration>
        <mainclass>com.xxx.yyy.mainapplication<mainclass>
      <configuration>
    <plugin>
  <plugins>
</build>

score:1

i had the same issue for multi module project and i added <mainclass>package-name-in-which-main-method-resides</mainclass> and it worked.

<build>
<plugins>
    <plugin>
        <groupid>org.springframework.boot</groupid>
        <artifactid>spring-boot-maven-plugin</artifactid>
    <configuration>
    <mainclass>package-name-where-@springbootapplication-main-method-is(com.agiletunes)</mainclass>
    </configuration>
    </plugin>
</plugins>
</build>

score:2

i also stumbled across this issue, and it turned out that packaging type was wrong. when i changed packaging from pom to jar, everything started to work correctly.

score:2

if you have multi modules maven project, as first workaround simply disable repackage to avoid this exception :

<properties>
    <spring-boot.repackage.skip>true</spring-boot.repackage.skip>
</properties>

other workarouds :

<executions>
      <execution>
          <goals>
               <goal>repackage</goal>
           </goals>
      </execution>
</executions>
<configuration>
      <skip>true</skip>
</configuration>

as solution:

  <properties>
        <spring.boot.mainclass>ir.shaparak.application</spring.boot.mainclass>
     </properties>

another solution: in parent pom do as follows:

<build>
    <pluginmanagement>
        <plugins>
            <plugin>
                <groupid>org.springframework.boot</groupid>
                <artifactid>spring-boot-maven-plugin</artifactid>
            </plugin>
        </plugins>
    </pluginmanagement>
</build>

in sub modules(runable moudles) should be as follows

   <build>
          <plugins>
                <plugin>
                    <groupid>org.springframework.boot</groupid>
                    <artifactid>spring-boot-maven-plugin</artifactid>
                </plugin>
           </plugins>
    </build>

score:4

wouldn't you simply tell it by using the annotation @springbootapplication?

https://docs.spring.io/spring-boot/docs/current/reference/html/using-boot-using-springbootapplication-annotation.html

many spring boot developers always have their main class annotated with @configuration, @enableautoconfiguration and @componentscan. since these annotations are so frequently used together (especially if you follow the best practices above), spring boot provides a convenient @springbootapplication alternative.

score:4

i was also facing the same issue is resolved by adding <id>repackage</id>.

 <plugins>
        <plugin>
            <groupid>org.springframework.boot</groupid>
            <artifactid>spring-boot-maven-plugin</artifactid>
            <executions>
                <execution>
                    <id>repackage</id>
                    <goals>
                        <goal>repackage</goal>
                    </goals>
                    <configuration>
                        <skip>true</skip>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>

score:6

i solved that,

add the following code to pom file,

<profiles>
    <profile>
        <id>profile1</id>
        <properties>
            <spring.boot.mainclass>com.detaysoft.application</spring.boot.mainclass>
        </properties>
    </profile>
</profiles>

then build the build tag as follows,

    <build>
    <plugins>
        <plugin>
            <groupid>org.springframework.boot</groupid>
            <artifactid>spring-boot-maven-plugin</artifactid>
            <executions>
                <execution>
                    <goals>
                        <goal>repackage</goal>
                    </goals>
                    <configuration>
                        <mainclass>${spring.boot.mainclass}</mainclass>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

score:10

i had a similar problem in the pom.xml created for separating my data model into a new module.

reading this tread i discovered i had accidentally put the <configuration><skip>true</skip></configuration> inside the <executions> block. below is my corrected pom.xml build section. fyi, there is no <packaging> entry in my pom.xml.

using ubuntu 20.04 lts, java 11.0.7, maven 3.6.3, spring starter 2.3.2.release, intellij 2020.2

working build configuration for pom.xml of my data model module

    <build>
        <plugins>
            <plugin>
                <groupid>org.springframework.boot</groupid>
                <artifactid>spring-boot-maven-plugin</artifactid>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <skip>true</skip>
                </configuration>
            </plugin>
        </plugins>
    </build>

score:18

in project agiletunes-util pom.xml add

<properties>
   <spring-boot.repackage.skip>true</spring-boot.repackage.skip>
</properties>

score:20

add property to maven properties like this

<properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    <start-class>org.roshan.application</start-class>
</properties>

score:32

i had the same problem. it ended being a spring boot mvn plugin declaration on a subproject that does not actually run (no main class). i just removed the spring boot mvn plugin from the submodule and everything ran fine

score:40

if you don't have a main class in springboot project, you can execution spring-boot-maven-plugin by follow

 <build>
        <plugins>
            <plugin>
                <groupid>org.springframework.boot</groupid>
                <artifactid>spring-boot-maven-plugin</artifactid>
                <configuration>
                    <skip>true</skip>
                </configuration>
            </plugin>
        </plugins>
</build>

score:50

you can try adding this in the properties section of your pom

<start-class>your.package.main</start-class>

score:113

you should have this

<build>
    <plugins>
        <plugin>
            <groupid>org.springframework.boot</groupid>
            <artifactid>spring-boot-maven-plugin</artifactid>
        </plugin>
    </plugins>
</build>

only in those modules that you want to run, but not in the parent pom.


Related Query

More Query from same tag