spring cloud问题总结

【1】默认生成的pom.xml文件,junit依赖jar没有配置版本,父工程pom文件加上 <version>2.1.4.RELEASE</version>,解决spring boot启动类编译错误问题

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-test</artifactId>
    <version>2.1.4.RELEASE</version>
    <scope>test</scope>
</dependency>

【2】启动类(@SpringBootApplication注解的类)要放在顶级父目录,如下图

所有的controller类都要放在com.szh包或者其子包下面,否则访问controller的时候会报white page错误

【3】启动eureka失败,console日志如下:

2019-04-09 15:49:02.301 ERROR 10856 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   :

***************************
APPLICATION FAILED TO START
***************************

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

    java.lang.invoke.MethodHandleNatives.resolve(Native Method)

The following method did not exist:

    com.google.gson.GsonBuilder.setLenient()Lcom/google/gson/GsonBuilder;

The method's class, com.google.gson.GsonBuilder, is available from the following locations:

    jar:file:/D:/Program%20Files/apache-maven-3.2.3/mvn_repository/com/google/code/gson/gson/2.1/gson-2.1.jar!/com/google/gson/GsonBuilder.class

It was loaded from the following location:

    file:/D:/Program%20Files/apache-maven-3.2.3/mvn_repository/com/google/code/gson/gson/2.1/gson-2.1.jar


Action:

Correct the classpath of your application so that it contains a single, compatible version of com.google.gson.GsonBuilder

问题原因:

gson 的jar版本不对,在“Extenal Libraries”下面找到gson包,修改jar版本,步骤如下:

1)点开"Extenal Libraries"

2)找到gson字样的jar包,右键单击

3)直接选择当前maven库中的最高版本

4)清理maven工程,重新启动spring boot,问题解决

转载于:https://my.oschina.net/u/3874846/blog/3034133

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值