1. 最近开始学习 SpringCloud,在搭建 Eureka Server 的时候遇到了 WebSecurityConfigurerAdapter.class cannot be opened 的报错,从博客上得知,如果不将入口类放置在一个包当中,则此时会将入口类放置于一个默认包中,而由于 SpringBoot 在初始化 bean 时会对所有包进行扫描,此时并未在pom.xml中Dependency引入Spring Security相关的包或Starter,从而导致找不到对应类。解决方式是将启动类放入一个包中。
2. springboot SocialConfigurerAdapter.class cannot be opened because it does not exist
出现该异常的原因在于不可以将启动类直接放置在 java 包下
3.IllegalArgumentException: Could not resolve placeholder in string value "${XXXXXX}"
出现该异常是有重复定义的 property-placeholder,解决方式是统一使用 context:property-placeholder 属性,并在标签中设置ignore-unresolvable="true":
<context:property-placeholder location="classpath:aa.properties" ignore-unresolvable="true" />
4.java.lang.IllegalStateException: Failed to introspect annotated methods on class org 这个报错的原因是 maven 引用依赖的<scope> 标签中的作用范围有问题,此时将 provided 改为 compile 即可。具体区别如下(详见博客):
compile:指的是编译范围有效,在编译和打包时都会将依赖存储进去
provided:在编译和测试的过程有效,最后生成war包时不会加入,诸如:servlet-api,因为servlet-api,tomcat等web服务器已经存在了,如果再打包会冲突
5. 尝试搭建《跟我学Spring Cloud》中的例子时,出现服务消费者无法注册到 Eureka 的情况,而且停止服务提供者的运行后,Eureka 当中的状态无法更新:
随后在 application.yml 中加入 eureka.server.enable-self-preservation = false 来关闭自我保护模式,依然无法改变已注册服务的状态,且出现 Eureka 将自身注册进服务的问题:
5.ApplicationContext is unlikely to start due to a @ComponentScan of the default package,该提示出现是因为将启动类直接放在了java目录下,需要新建一个子目录来放置启动类。