Spring boot and maven exec plugin issue

后端 未结 1 1745
日久生厌
日久生厌 2021-01-04 09:22

I\'ve created a bare-bone Maven project, completely empty except the pom.xml.

With this pom (note that parent element is commented-out):

1条回答
  •  青春惊慌失措
    2021-01-04 10:15

    Its because Spring-Boot is adding some extra maven configuration to your project. If you are using eclipse, there's a Tab called: 'Effective POM'.

    From this tab you can see that it adds this snippet below:

        
          org.codehaus.mojo
          exec-maven-plugin
          1.2.1
          
            ${start-class}
          
        
    

    So when you run it with spring-boot as parent, it looks for the value of ${start-class}, which resolves to empty unless you defined it, that's when you see the error about not having a value for the mainClass parameter.

    Add this to your project:

    
        com.Test
    
    

    Then run it: clean compile exec:java

    [INFO] --- exec-maven-plugin:1.2.1:java (default-cli) @ springboot-test ---
    **********test**************
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESS
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 2.388 s
    [INFO] Finished at: 2014-12-05T15:25:05-06:00
    [INFO] Final Memory: 17M/231M
    [INFO] ------------------------------------------------------------------------
    

    You can also provide the value for the start-class property on the command line, this works even if you didn't define it inside your pom file:

    mvn exec:java -Dstart-class=com.Test

    0 讨论(0)
提交回复
热议问题