java - 需要一个找不到的“de.codecentric.boot.admin.server.config.AdminServerProperties”类型的 bean
问题描述
我有这个问题
需要一个找不到的“de.codecentric.boot.admin.server.config.AdminServerProperties”类型的 bean
考虑在配置中定义“de.codecentric.boot.admin.server.config.AdminServerProperties”类型的 bean。
这是我的 POM
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<!--Add login page and logout feature -->
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-server</artifactId>
<version>2.2.2</version>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server</artifactId>
<version>2.2.2</version>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server-ui</artifactId>
<version>2.2.2</version>
</dependency>
<!--Add login page and logout feature -->
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server-ui-login</artifactId>
<version>1.5.7</version>
</dependency>
<dependency>
<groupId>com.hazelcast</groupId>
<artifactId>hazelcast</artifactId>
</dependency>
<!--declare the admin server as a client, for self monitoring -->
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
<version>2.2.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
知道是什么原因吗?
公共类 WebSecurityConfig 扩展 WebSecurityConfigurerAdapter {
private final AdminServerProperties adminServer;
public WebSecurityConfig(AdminServerProperties adminServer) {
this.adminServer = adminServer;
}
解决方案
在主类(@SpringBootApplication)上方添加@Import(AdminServerProperties.class)就足够了
推荐阅读
- javascript - 将二维数组转换为一维数组,交替其值
- vb.net - 如何以编程方式在 RichTextBox 中添加 Button 控件?
- css - 剪辑路径总是溢出:隐藏
- c# - NLog:使用 NLog 的包装类时记录行号和调用方法
- prolog - prolog 的类型问题
- travis-ci - 如何使用 tox-travis 单独运行命令
- assembly - RISC-V 分支偏移机器指令编码
- wpf - 如何在 GridView 绑定中获取当前单元格值
- go - AWS Lambda GoLang 处理程序 API
- postgresql - postgres 触发器无法正常工作 - id 参数未正确传递给新表