eclipse 关机按钮无法关机嵌入式 tomcat 用于 spring 启动
eclipse shutdown button can not shutdown embedded tomcat used fo spring boot
我在 spring 启动应用程序中使用嵌入式 tomcat。
我调整应用程序的目标如下:
clean spring-boot:run
并且 运行 没有错误。我使用 Eclipse 关机按钮将其关闭。
我第二次尝试 运行 我得到了这个:
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 下次无法删除目标。我的 tomcat 怎么了?
我做错了什么吗?
我在application.yml中的服务器配置:
server:
compression:
enabled: true
port: 8080
servlet-path: /rest
和我的 tomcat 依赖关系:
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
要解决此问题,请更改 tomcat maven plugin
并将 fork
添加到 false
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>false</fork>
</configuration>
</plugin>
我写了这个 bat 脚本命令:
FOR /F "tokens=5 delims= " %%P IN ('netstat -a -n -o ^| findstr :8080.*LISTENING') DO TaskKill.exe /PID %%P /F
pause
并将其保存在 killport.bat
中,然后使用 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>
只需将以下标签添加到 pom.xml 文件中的 spring-boot-maven-plugin
<configuration>
<fork>false</fork>
</configuration>
这里是完整的例子:
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>false</fork>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
我在 spring 启动应用程序中使用嵌入式 tomcat。 我调整应用程序的目标如下:
clean spring-boot:run
并且 运行 没有错误。我使用 Eclipse 关机按钮将其关闭。 我第二次尝试 运行 我得到了这个:
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 下次无法删除目标。我的 tomcat 怎么了? 我做错了什么吗?
我在application.yml中的服务器配置:
server:
compression:
enabled: true
port: 8080
servlet-path: /rest
和我的 tomcat 依赖关系:
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
要解决此问题,请更改 tomcat maven plugin
并将 fork
添加到 false
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>false</fork>
</configuration>
</plugin>
我写了这个 bat 脚本命令:
FOR /F "tokens=5 delims= " %%P IN ('netstat -a -n -o ^| findstr :8080.*LISTENING') DO TaskKill.exe /PID %%P /F
pause
并将其保存在 killport.bat
中,然后使用 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>
只需将以下标签添加到 pom.xml 文件中的 spring-boot-maven-plugin
<configuration>
<fork>false</fork>
</configuration>
这里是完整的例子:
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>false</fork>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>