Could not exec java with Spring+Maven exit code 1

Sometimes the port might just be already in use, make sure you kill all java processes before running an application.


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:

<dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <!-- Exclusions to allow SpringBoot execute on HCP -->
        <!--<exclusions>-->
            <!--<exclusion>-->
                <!--<groupId>org.springframework.boot</groupId>-->
                <!--<artifactId>spring-boot-starter-tomcat</artifactId>-->
            <!--</exclusion>-->
            <!--<exclusion>-->
                <!--<groupId>org.apache.tomcat.embed</groupId>-->
                <!--<artifactId>tomcat-embed-el</artifactId>-->
            <!--</exclusion>-->
            <!--<exclusion>-->
                <!--<artifactId>logback-classic</artifactId>-->
                <!--<groupId>ch.qos.logback</groupId>-->
            <!--</exclusion>-->
        <!--</exclusions>-->
    </dependency>

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.