我正在尝试使我的Java应用程序在进行更改后自动更新。当我更改html或css文件时,自动更新内容可以正常工作,但是当我更改java类时,我的项目会自动重建,但会引发错误。当我停止并单击以重新运行我的应用程序时,一切正常。
我正在使用intellij Idea ide,我在这里更改了2种设置
在我启用的注册表中的菜单shift + cltr + a中,允许在运行时进行编译
在构建设置中,我启用了自动构建
我将非常感谢您的帮助。
我得到的错误
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2018-07-09 01:09:37.490 ERROR 212 --- [ restartedMain] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$EnableWebMvcConfiguration': Unsatisfied dependency expressed through method 'setConfigurers' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter': Unexpected exception during bean creation; nested exception is org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class org.springframework.boot.autoconfigure.http.HttpMessageConverters: Common causes of this problem include using a final class or a non-visible class; nested exception is org.springframework.cglib.core.CodeGenerationException: java.lang.LinkageError-->loader (instance of jdk/internal/loader/ClassLoaders$AppClassLoader): attempted duplicate class definition for name: "org/springframework/boot/autoconfigure/http/HttpMessageConverters$$EnhancerBySpringCGLIB$$1d90bff9"
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:673) ~[spring-beans-5.1.0.BUILD-20180708.121145-240.jar:5.1.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:91) ~[spring-beans-5.1.0.BUILD-20180708.121145-240.jar:5.1.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:371) ~[spring-beans-5.1.0.BUILD-20180708.121145-240.jar:5.1.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1352) ~[spring-beans-5.1.0.BUILD-20180708.121145-240.jar:5.1.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:574) ~[spring-beans-5.1.0.BUILD-20180708.121145-240.jar:5.1.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:497) ~[spring-beans-5.1.0.BUILD-20180708.121145-240.jar:5.1.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) ~[spring-beans-5.1.0.BUILD-20180708.121145-240.jar:5.1.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.1.0.BUILD-20180708.121145-240.jar:5.1.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) ~[spring-beans-5.1.0.BUILD-20180708.121145-240.jar:5.1.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.1.0.BUILD-20180708.121145-240.jar:5.1.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:759) ~[spring-beans-5.1.0.BUILD-20180708.121145-240.jar:5.1.0.BUILD-SNAPSHOT]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:869) ~[spring-context-5.1.0.BUILD-20180708.121145-240.jar:5.1.0.BUILD-SNAPSHOT]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) ~[spring-context-5.1.0.BUILD-20180708.121145-240.jar:5.1.0.BUILD-SNAPSHOT]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.1.0.BUILD-20180706.150128-217.jar:2.1.0.BUILD-SNAPSHOT]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:762) [spring-boot-2.1.0.BUILD-20180706.150128-217.jar:2.1.0.BUILD-SNAPSHOT]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:398) [spring-boot-2.1.0.BUILD-20180706.150128-217.jar:2.1.0.BUILD-SNAPSHOT]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:330) [spring-boot-2.1.0.BUILD-20180706.150128-217.jar:2.1.0.BUILD-SNAPSHOT]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1234) [spring-boot-2.1.0.BUILD-20180706.150128-217.jar:2.1.0.BUILD-SNAPSHOT]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1222) [spring-boot-2.1.0.BUILD-20180706.150128-217.jar:2.1.0.BUILD-SNAPSHOT]
at com.zerg.myWebsite.MyWebsiteApplication.main(MyWebsiteApplication.java:12) [classes/:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:564) ~[na:na]
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-2.1.0.BUILD-20180706.150038-217.jar:2.1.0.BUILD-SNAPSHOT]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter': Unexpected exception during bean creation; nested exception is org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class org.springframework.boot.autoconfigure.http.HttpMessageConverters: Common causes of this problem include using a final class or a non-visible class; nested exception is org.springframework.cglib.core.CodeGenerationException: java.lang.LinkageError-->loader (instance of jdk/internal/loader/ClassLoaders$AppClassLoader): attempted duplicate class definition for name: "org/springframework/boot/autoconfigure/http/HttpMessageConverters$$EnhancerBySpringCGLIB$$1d90bff9"
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:510) ~[spring-beans-5.1.0.BUILD-20180708.121145-240.jar:5.1.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) ~[spring-beans-5.1.0.BUILD-20180708.121145-240.jar:5.1.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.1.0.BUILD-20180708.121145-240.jar:5.1.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) ~[spring-beans-5.1.0.BUILD-20180708.121145-240.jar:5.1.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.1.0.BUILD-20180708.121145-240.jar:5.1.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:252) ~[spring-beans-5.1.0.BUILD-20180708.121145-240.jar:5.1.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.addCandidateEntry(DefaultListableBeanFactory.java:1320) ~[spring-beans-5.1.0.BUILD-20180708.121145-240.jar:5.1.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1286) ~[spring-beans-5.1.0.BUILD-20180708.121145-240.jar:5.1.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveMultipleBeans(DefaultListableBeanFactory.java:1188) ~[spring-beans-5.1.0.BUILD-20180708.121145-240.jar:5.1.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1091) ~[spring-beans-5.1.0.BUILD-20180708.121145-240.jar:5.1.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1060) ~[spring-beans-5.1.0.BUILD-20180708.121145-240.jar:5.1.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:665) ~[spring-beans-5.1.0.BUILD-20180708.121145-240.jar:5.1.0.BUILD-SNAPSHOT]
... 24 common frames omitted
Caused by: org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class org.springframework.boot.autoconfigure.http.HttpMessageConverters: Common causes of this problem include using a final class or a non-visible class; nested exception is org.springframework.cglib.core.CodeGenerationException: java.lang.LinkageError-->loader (instance of jdk/internal/loader/ClassLoaders$AppClassLoader): attempted duplicate class definition for name: "org/springframework/boot/autoconfigure/http/HttpMessageConverters$$EnhancerBySpringCGLIB$$1d90bff9"
at org.springframework.aop.framework.CglibAopProxy.getProxy(CglibAopProxy.java:208) ~[spring-aop-5.1.0.BUILD-20180708.121145-240.jar:5.1.0.BUILD-SNAPSHOT]
at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:110) ~[spring-aop-5.1.0.BUILD-20180708.121145-240.jar:5.1.0.BUILD-SNAPSHOT]
at org.springframework.context.annotation.ContextAnnotationAutowireCandidateResolver.buildLazyResolutionProxy(ContextAnnotationAutowireCandidateResolver.java:117) ~[spring-context-5.1.0.BUILD-20180708.121145-240.jar:5.1.0.BUILD-SNAPSHOT]
at org.springframework.context.annotation.ContextAnnotationAutowireCandidateResolver.getLazyResolutionProxyIfNecessary(ContextAnnotationAutowireCandidateResolver.java:52) ~[spring-context-5.1.0.BUILD-20180708.121145-240.jar:5.1.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1057) ~[spring-beans-5.1.0.BUILD-20180708.121145-240.jar:5.1.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:818) ~[spring-beans-5.1.0.BUILD-20180708.121145-240.jar:5.1.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:724) ~[spring-beans-5.1.0.BUILD-20180708.121145-240.jar:5.1.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:197) ~[spring-beans-5.1.0.BUILD-20180708.121145-240.jar:5.1.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1278) ~[spring-beans-5.1.0.BUILD-20180708.121145-240.jar:5.1.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1135) ~[spring-beans-5.1.0.BUILD-20180708.121145-240.jar:5.1.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537) ~[spring-beans-5.1.0.BUILD-20180708.121145-240.jar:5.1.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:497) ~[spring-beans-5.1.0.BUILD-20180708.121145-240.jar:5.1.0.BUILD-SNAPSHOT]
... 35 common frames omitted
Caused by: org.springframework.cglib.core.CodeGenerationException: java.lang.LinkageError-->loader (instance of jdk/internal/loader/ClassLoaders$AppClassLoader): attempted duplicate class definition for name: "org/springframework/boot/autoconfigure/http/HttpMessageConverters$$EnhancerBySpringCGLIB$$1d90bff9"
at org.springframework.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:502) ~[spring-core-5.1.0.BUILD-20180708.121145-240.jar:5.1.0.BUILD-SNAPSHOT]
at org.springframework.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:359) ~[spring-core-5.1.0.BUILD-20180708.121145-240.jar:5.1.0.BUILD-SNAPSHOT]
at org.springframework.cglib.proxy.Enhancer.generate(Enhancer.java:582) ~[spring-core-5.1.0.BUILD-20180708.121145-240.jar:5.1.0.BUILD-SNAPSHOT]
at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:106) ~[spring-core-5.1.0.BUILD-20180708.121145-240.jar:5.1.0.BUILD-SNAPSHOT]
at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:104) ~[spring-core-5.1.0.BUILD-20180708.121145-240.jar:5.1.0.BUILD-SNAPSHOT]
at org.springframework.cglib.core.internal.LoadingCache$2.call(LoadingCache.java:54) ~[spring-core-5.1.0.BUILD-20180708.121145-240.jar:5.1.0.BUILD-SNAPSHOT]
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[na:na]
at org.springframework.cglib.core.internal.LoadingCache.createEntry(LoadingCache.java:61) ~[spring-core-5.1.0.BUILD-20180708.121145-240.jar:5.1.0.BUILD-SNAPSHOT]
at org.springframework.cglib.core.internal.LoadingCache.get(LoadingCache.java:34) ~[spring-core-5.1.0.BUILD-20180708.121145-240.jar:5.1.0.BUILD-SNAPSHOT]
at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData.get(AbstractClassGenerator.java:130) ~[spring-core-5.1.0.BUILD-20180708.121145-240.jar:5.1.0.BUILD-SNAPSHOT]
at org.springframework.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:315) ~[spring-core-5.1.0.BUILD-20180708.121145-240.jar:5.1.0.BUILD-SNAPSHOT]
at org.springframework.cglib.proxy.Enhancer.createHelper(Enhancer.java:569) ~[spring-core-5.1.0.BUILD-20180708.121145-240.jar:5.1.0.BUILD-SNAPSHOT]
at org.springframework.cglib.proxy.Enhancer.createClass(Enhancer.java:416) ~[spring-core-5.1.0.BUILD-20180708.121145-240.jar:5.1.0.BUILD-SNAPSHOT]
at org.springframework.aop.framework.ObjenesisCglibAopProxy.createProxyClassAndInstance(ObjenesisCglibAopProxy.java:58) ~[spring-aop-5.1.0.BUILD-20180708.121145-240.jar:5.1.0.BUILD-SNAPSHOT]
at org.springframework.aop.framework.CglibAopProxy.getProxy(CglibAopProxy.java:205) ~[spring-aop-5.1.0.BUILD-20180708.121145-240.jar:5.1.0.BUILD-SNAPSHOT]
... 46 common frames omitted
Caused by: java.lang.LinkageError: loader (instance of jdk/internal/loader/ClassLoaders$AppClassLoader): attempted duplicate class definition for name: "org/springframework/boot/autoconfigure/http/HttpMessageConverters$$EnhancerBySpringCGLIB$$1d90bff9"
at java.base/java.lang.ClassLoader.defineClass1(Native Method) ~[na:na]
at java.base/java.lang.System$2.defineClass(System.java:2131) ~[na:na]
at java.base/java.lang.invoke.MethodHandles$Lookup.defineClass(MethodHandles.java:964) ~[na:na]
at java.base/jdk.internal.reflect.GeneratedMethodAccessor31.invoke(Unknown Source) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:564) ~[na:na]
at org.springframework.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:498) ~[spring-core-5.1.0.BUILD-20180708.121145-240.jar:5.1.0.BUILD-SNAPSHOT]
... 60 common frames omitted
我的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.zerg</groupId>
<artifactId>myWebsite</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>myWebsite</name>
<description>My website project.</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.0.BUILD-SNAPSHOT</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>10</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-security</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>org.springframework.session</groupId>
<artifactId>spring-session-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</project>
我的application.properties文件
#spring.jpa.hibernate.ddl-auto=create
spring.datasource.type=com.zaxxer.hikari.HikariDataSource
spring.datasource.url=jdbc:mysql://localhost:3306/webproject?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC&useSSL=false
spring.datasource.username=admin
spring.datasource.password=admin
#Hikari will use the above plus the following to setup connection pooling
spring.datasource.hikari.minimumIdle=5
spring.datasource.hikari.maximumPoolSize=20
spring.datasource.hikari.idleTimeout=30000
spring.datasource.hikari.poolName=SpringBootJPAHikariCP
spring.datasource.hikari.maxLifetime=2000000
spring.datasource.hikari.connectionTimeout=30000
spring.thymeleaf.cache=false
我的SpringBootApplication文件
package com.zerg.myWebsite;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class MyWebsiteApplication {
public static void main(String[] args) {
SpringApplication.run(MyWebsiteApplication.class, args);
}
}
我正在测试更改的Controller类
package com.zerg.myWebsite.controller;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
@Controller
public class HomeController {
@GetMapping("/home")
public String home(@RequestParam(name = "DevTools", required = false, defaultValue = "Testing!") String name,
Model model) {
model.addAttribute("name", name);
String test = "test liveloader";
model.addAttribute("getString", test);
return "home.html";
}
}
我的html文件
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Getting Started: Serving Web Content</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<h1>Testing Spring Devtools!</h1>
<p th:text="'SpringFramework, ' + ${name} + '!'"></p>
<p th:text="'SpringFramework, ' + ${getString} + '!'"></p>
</body>
</html>
在较早版本的spring-boot 2.0.3中,html自动更新正在运行,但是当我更改java类时,一切都在构建并且可以正常编译,但是我的Chrome网页无法加载,会给出错误
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Mon Jul 09 15:29:48 CEST 2018
There was an unexpected error (type=Not Found, status=404).
No message available
当我在SpringBootApplication类中更改某些内容并保存更改后,它会自动生成,并且一切正常,我的html页面以chrome显示,但是当我更改其他java类时,会显示上面的错误。