Joh*_*des 8 java eclipse maven spring-boot spring-boot-devtools
我使用Spring,JPA,MySQL和Web构建了一个应用程序.我正常在模板文件夹中开发了一个静态页面,它可以工作.
但是,当我在静态页面上更改某些内容时,我无法通过更改重新加载它.然后,我打开pom.xml并添加
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
Run Code Online (Sandbox Code Playgroud)
我重新启动应用程序,但是,当我在静态页面上进行一些更改时,仍然无法正常工作.
还有什么可以做的吗?
我的POM.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.engsoftware</groupId>
<artifactId>cobranca</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>Cobranca</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Run Code Online (Sandbox Code Playgroud)
use*_*069 12
在你的eclipse顶级菜单中你的"项目" - >"自动构建"开启吗?
我关注了这篇文章https://github.com/spring-projects/spring-boot/issues/7479
因此,要使devtools正常工作,必须添加:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
<scope>runtime</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)
秘诀是添加可选的True和Scope运行时。
这个问题已经被回答了,但是对我来说,它并没有完全按照公认的答案或其他答案来回答。
我有devtools以下列方式工作:
1)使用devtools依赖项,如下所示:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
<scope>runtime</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)
2)在Linux中,删除Spring Maven缓存将是:
rm -rf ~/.m2/repository/org/springframework/*
Run Code Online (Sandbox Code Playgroud)
3)返回Eclipse,按Alt + F5并强制清理项目,将每个依赖项从Maven重新下载到缓存。
关键是将optional
标志设置true
为devtools的依赖项并擦除Maven缓存。
希望这对某人有帮助。
归档时间: |
|
查看次数: |
15256 次 |
最近记录: |