SpringBoot2常见问题总结帖

1. 启动Springboot主程序类后报错This application has no explicit mapping for /error, so you are seeing this as a fallback.

解决办法:

MainApplication位置放错了,需要放在最外面,放在某一个包如controller中就会报错,同时检查自己的注解是否写错,@SpringBootApplication。

2.打包SpringBoot项目报错

Could not transfer artifact org.apache.maven.surefire:surefire-junit4:pom:2.22.1 from/to central (https://repo.maven.apache.org/maven2): Transfer failed for https://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-junit4/2.22.1/surefire-junit4-2.22.1.pom

解决办法:没有导入打包所需的插件,添加至pom.xml文件即可

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.18.1</version>
            <configuration>
                <skipTests>true</skipTests>
            </configuration>
        </plugin>
    </plugins>
</build>

3.IDEA的热部署方式-On Update action与On Frame deactivation

在配置中找到On Update actionOn Frame deactivation选项:

On Update action 里面有四个选项(一般选Update classes and resources):

    -Update resources :如果发现有更新,而且更新的是资源文件(*.jsp,*.xml等,不包括java文件),就会立刻生效

    -Update classes and resources : 如果发现有更新,这个是同时包含java文件和资源文件的,就会立刻生效(在运行模式下,修改java文件时不会立刻生效的;而debug模式下,修改java文件时可以立刻生效的。当然,两种运行模式下,修改resources资源文件都是可以立刻生效的)

    -Redploy : 重新部署,只是把原来的war删掉,不重启服务器

    -Restart : 重启服务器

On Frame deactivation:

     -Do nothing : 不做任何事 (一般推荐这个,因为失去焦点的几率太大)

     -Update resources : 失去焦点后,修改的resources文件都会立刻生效

    -Update classes and resources : 失去焦点后,修改的java ,resources文件都会立刻生效(与On update action中的Update classes and resources一样,也是运行模式修改的java文件不会生效,debug模式修改的java文件会立刻生效)

如果要更新Thymeleaf这种前端资源,需要在配置文件中把缓存关掉,否则是无法更新的。

spring.thymeleaf.cache=false

4.Thymeleaf在Springboot中没有提示

首先要确定加载了Thymeleaf的依赖,

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>

之后要在html头中加入命名空间,少个http不行,https也不行,必须要按着下面的格式写

<html lang="en" xmlns:th="http://www.thymeleaf.org">

5.Eureka的Client端启动报错

Failed to introspect Class [org.springframework.cloud.netflix.eureka.config.

解决:导入依赖时缺少starter

<dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
        </dependency>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值