spring 版本 2.1.4
1.
問題: 添加 spring-security 后 無法注冊。
原因 : spring boot 2.x 添加了 csrf 驗證 。
解決 :
package boot.zero.eureka.conf; import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; @Configuration public class SecurityConfig extends WebSecurityConfigurerAdapter { @Override protected void configure(HttpSecurity http) throws Exception { http.csrf().disable(); super.configure(http); } }
注冊 時寫法:
eureka: client: service-url: defaultZone: http://admin:admin@localhost:8080/eureka/
2.
問題 : /actuator/info 沒有信息
解決: 執行一遍 maven 命令 spring-boot: build-info