Could not exec java with Spring+Maven exit code 1

后端 未结 5 1254
梦如初夏
梦如初夏 2021-01-18 03:07

I am new to Spring/Maven, and am following this tutorial: Serving Web Content with Spring MVC.

Everytime I run mvn spring-boot:run, I get this error:

5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-18 03:07

    I made the following changes to make mvn clean spring-boot:run work:

    • Move pom.xml to the root directory, which makes the directory hierarchy to be:

    Directory hierarchy:

    .
    ├── pom.xml
    └── src
        └── main
            ├── java
            │   └── hello
            │       ├── Application.java
            │       └── GreetingController.java
            └── resources
                └── templates
                    └── greeting.html
    
    • Commented out the extensions in the following part:

    Commented out part:

    
            org.springframework.boot
            spring-boot-starter-web
            
            
                
                    
                    
                
                
                    
                    
                
                
                    
                    
                
            
        
    

    It seems you meant to exclude those dependencies. mvn clean spring-boot:run will just exit successfully if the embed tomcat is excluded, but I think this is the correct behave because there's no container to deploy the application. Anyway, you can try it out and make changes according your requirements.

提交回复
热议问题