====================================
首先需要一个服务注册中心Eureka Server,让Spring Boot Admin(以下简称 SBA)服务端向它注册服务。
创建新的module admin-server,pom.xml 如下:
xsi:schemaLocation=“http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd”> 4.0.0 com.springcloud.demo springcloud-demo 1.0-SNAPSHOT admin-server 0.0.1-SNAPSHOT jar admin-server Demo project for Spring Boot org.springframework.boot spring-boot-starter-actuator de.codecentric spring-boot-admin-starter-server 2.0.1 org.springframework.cloud spring-cloud-starter-netflix-eureka-client org.jolokia jolokia-core org.springframework.cloud spring-cloud-starter-security org.springframework.boot spring-boot-starter-test test org.springframework.boot spring-boot-maven-plugin 改版本的 spring cloud 没有相应的 spring-boot-admin-starter-server 版本,这里使用2.0.1 版本,需加上版本号。 启动类加上注解@EnableAdminServer和@EnableEurekaClient @EnableEurekaClient @EnableAdminServer @SpringBootApplication @ComponentScan(“com.springcloud.demo.adminserver”) public class AdminServerApplication { public static void main(String[] args) { SpringApplication.run(AdminServerApplication.class, args); } } 配置文件配置端口号、程序名、服务注册中心地址和安全配置: server.port=5000 spring.application.name=admin-server spring.security.user.name=admin spring.security.user.password=admin eureka.instance.metadata-map.user.name=${spring.security.user.name} eureka.instance.metadata-map.user.password=${spring.security.user.password} eureka.client.service-url.defaultZone=http://localhost:8791/eureka/ eureka.instance.health-check-url-path=/actuator/health management.endpoints.web.exposure.include=* management.endpoint.health.show-details=always 新增一个安全配置类。 @Configuration public class SecuritySecureConfig extends WebSecurityConfigurerAdapter { private final String adminContextPath; public SecuritySecureConfig(AdminServerProperties adminServerProperties) { this.adminContextPath = adminServerProperties.getContextPath(); } @Override protected void configure(HttpSecurity http) throws Exception { // @formatter:off SavedRequestAwareAuthenticationSuccessHandler successHandler = new SavedRequestAwareAuthenticationSuccessHandler(); successHandler.setTargetUrlParameter(“redirectTo”); http.authorizeRequests() .antMatchers(adminContextPath + “/assets/**”).permitAll() .antMatchers(adminContextPath + “/login”).permitAll() 面试资料整理汇总 这些面试题是我朋友进阿里前狂刷七遍以上的面试资料,由于面试文档很多,内容更多,没有办法一一为大家展示出来,所以只好为大家节选出来了一部分供大家参考。 面试的本质不是考试,而是告诉面试官你会做什么,所以,这些面试资料中提到的技术也是要学会的,不然稍微改动一下你就凉凉了 在这里祝大家能够拿到心仪的offer! rmitAll() 面试资料整理汇总 [外链图片转存中…(img-Fb9yBl4p-1710368134195)] [外链图片转存中…(img-uSqIO4UI-1710368134196)] 这些面试题是我朋友进阿里前狂刷七遍以上的面试资料,由于面试文档很多,内容更多,没有办法一一为大家展示出来,所以只好为大家节选出来了一部分供大家参考。 面试的本质不是考试,而是告诉面试官你会做什么,所以,这些面试资料中提到的技术也是要学会的,不然稍微改动一下你就凉凉了 在这里祝大家能够拿到心仪的offer! 好文阅读
发表评论