required a bean of type 'de.codecentric.boot.admin.server.config.AdminServerProperties' that could not be found

huangapple go评论90阅读模式
英文:

required a bean of type 'de.codecentric.boot.admin.server.config.AdminServerProperties' that could not be found

问题

我遇到了这个问题: 

需要一个名为 "de.codecentric.boot.admin.server.config.AdminServerProperties" 的 bean,但找不到该类型的 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>

    <!-- 添加登录页面和注销功能 -->
    <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>
    <!-- 添加登录页面和注销功能 -->
    <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>
    <!-- 将管理服务器声明为客户端,用于自我监控 -->
    <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>

有什么想法是什么原因导致的吗?

public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

    private final AdminServerProperties adminServer;

    public WebSecurityConfig(AdminServerProperties adminServer) {
        this.adminServer = adminServer;
    }
英文:

i am having this issue of

required a bean of type "de.codecentric.boot.admin.server.config.AdminServerProperties" that could not be found

Consider defining a bean of type "de.codecentric.boot.admin.server.config.AdminServerProperties" in your configuration.

here is my POM

&lt;dependencies&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;
        &lt;artifactId&gt;spring-cloud-starter-netflix-eureka-client&lt;/artifactId&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
        &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
    &lt;/dependency&gt;
	
    &lt;dependency&gt;
        &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
        &lt;artifactId&gt;spring-boot-starter-security&lt;/artifactId&gt;
    &lt;/dependency&gt;

	&lt;!--Add login page and logout feature --&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;de.codecentric&lt;/groupId&gt;
        &lt;artifactId&gt;spring-boot-admin-starter-server&lt;/artifactId&gt;
        &lt;version&gt;2.2.2&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;de.codecentric&lt;/groupId&gt;
        &lt;artifactId&gt;spring-boot-admin-server&lt;/artifactId&gt;
        &lt;version&gt;2.2.2&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;de.codecentric&lt;/groupId&gt;
        &lt;artifactId&gt;spring-boot-admin-server-ui&lt;/artifactId&gt;
        &lt;version&gt;2.2.2&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;!--Add login page and logout feature --&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;de.codecentric&lt;/groupId&gt;
        &lt;artifactId&gt;spring-boot-admin-server-ui-login&lt;/artifactId&gt;
        &lt;version&gt;1.5.7&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;com.hazelcast&lt;/groupId&gt;
        &lt;artifactId&gt;hazelcast&lt;/artifactId&gt;
    &lt;/dependency&gt;
    &lt;!--declare the admin server as a client, for self monitoring --&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;de.codecentric&lt;/groupId&gt;
        &lt;artifactId&gt;spring-boot-admin-starter-client&lt;/artifactId&gt;
        &lt;version&gt;2.2.2&lt;/version&gt;
    &lt;/dependency&gt;
	 
    &lt;dependency&gt;
        &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
        &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
        &lt;scope&gt;test&lt;/scope&gt;
        &lt;exclusions&gt;
            &lt;exclusion&gt;
                &lt;groupId&gt;org.junit.vintage&lt;/groupId&gt;
                &lt;artifactId&gt;junit-vintage-engine&lt;/artifactId&gt;
            &lt;/exclusion&gt;
        &lt;/exclusions&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
        &lt;artifactId&gt;spring-security-test&lt;/artifactId&gt;
        &lt;scope&gt;test&lt;/scope&gt;
    &lt;/dependency&gt;

    &lt;dependency&gt;
        &lt;groupId&gt;junit&lt;/groupId&gt;
        &lt;artifactId&gt;junit&lt;/artifactId&gt;
        &lt;version&gt;4.11&lt;/version&gt;
        &lt;scope&gt;test&lt;/scope&gt;
    &lt;/dependency&gt;
&lt;/dependencies&gt;

any idea what is the cause?

public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

private final AdminServerProperties adminServer;

public WebSecurityConfig(AdminServerProperties adminServer) {
    this.adminServer = adminServer;
}

答案1

得分: 1

@Import(AdminServerProperties.class) 添加到主类(@SpringBootApplication 上面)就足够了。

英文:

It will be enough add @Import(AdminServerProperties.class) above the main class (@SpringBootApplication)

huangapple
  • 本文由 发表于 2020年4月11日 11:41:28
  • 转载请务必保留本文链接:https://go.coder-hub.com/61151845.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定