Hadi Rasouli
Hadi Rasouli

Reputation: 2037

eclipse shutdown button can not shutdown embedded tomcat used fo spring boot

I'm using embedded tomcat in my spring boot application. I tun application with goal below:

clean spring-boot:run

and it runs with no error. I use eclipse shutdown button to shut it down. second time i try to run it i get this :

Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.5:clean (default-clean) on project cpanel: Failed to clean project: Failed to delete XXXXXXXXX\target\classes\hibernate\security\user\User.hbm.xml -> [Help 1]

it sims tomcat can't delete target for next time. whats wrong with my tomcat? Am i doing some thing wrong?

My server configuration in application.yml:

server:
compression:
    enabled: true
port: 8080
servlet-path: /rest

and my tomcat dependency:

<dependency>
    <groupId>org.apache.tomcat.embed</groupId>
    <artifactId>tomcat-embed-jasper</artifactId>
    <scope>provided</scope>
</dependency>

Upvotes: 2

Views: 1617

Answers (3)

Mohammad lockman
Mohammad lockman

Reputation: 158

Just add the following Tag in to the spring-boot-maven-plugin in the pom.xml file

            <configuration>
                <fork>false</fork>
            </configuration>

here is the full Example :

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                    <configuration>
                        <fork>false</fork>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

Upvotes: 0

Rasool Ghafari
Rasool Ghafari

Reputation: 4278

I wrote this bat script command:

FOR /F "tokens=5 delims= " %%P IN ('netstat -a -n -o ^| findstr :8080.*LISTENING') DO TaskKill.exe /PID %%P /F pause and saved it in killport.bat, then called it with maven-antrun-plugin:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-antrun-plugin</artifactId>
    <version>1.6</version>
    <executions>
        <execution>
            <phase>compile</phase>
            <configuration>
                <target>
                    <exec executable="cmd.exe" spawn="true">
                        <arg value="/c" />
                        <arg value="F:\Java\Projects\killport.bat" />
                    </exec>
                </target>
            </configuration>
            <goals>
                <goal>run</goal>
            </goals>
        </execution>
    </executions>
</plugin>

Upvotes: 1

ali akbar azizkhani
ali akbar azizkhani

Reputation: 2289

To solve this problem, change tomcat maven plugin and add fork to false

   <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <configuration>
            <fork>false</fork>
        </configuration>
  </plugin>

Upvotes: 3

Related Questions