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

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

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

问题

  1. 我遇到了这个问题:
  2. 需要一个名为 "de.codecentric.boot.admin.server.config.AdminServerProperties" bean,但找不到该类型的 bean
  3. 请在您的配置中定义一个类型为 "de.codecentric.boot.admin.server.config.AdminServerProperties" bean
  4. 这是我的 POM
  5. <dependencies>
  6. <dependency>
  7. <groupId>org.springframework.cloud</groupId>
  8. <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
  9. </dependency>
  10. <dependency>
  11. <groupId>org.springframework.boot</groupId>
  12. <artifactId>spring-boot-starter-web</artifactId>
  13. </dependency>
  14. <dependency>
  15. <groupId>org.springframework.boot</groupId>
  16. <artifactId>spring-boot-starter-security</artifactId>
  17. </dependency>
  18. <!-- 添加登录页面和注销功能 -->
  19. <dependency>
  20. <groupId>de.codecentric</groupId>
  21. <artifactId>spring-boot-admin-starter-server</artifactId>
  22. <version>2.2.2</version>
  23. </dependency>
  24. <dependency>
  25. <groupId>de.codecentric</groupId>
  26. <artifactId>spring-boot-admin-server</artifactId>
  27. <version>2.2.2</version>
  28. </dependency>
  29. <dependency>
  30. <groupId>de.codecentric</groupId>
  31. <artifactId>spring-boot-admin-server-ui</artifactId>
  32. <version>2.2.2</version>
  33. </dependency>
  34. <!-- 添加登录页面和注销功能 -->
  35. <dependency>
  36. <groupId>de.codecentric</groupId>
  37. <artifactId>spring-boot-admin-server-ui-login</artifactId>
  38. <version>1.5.7</version>
  39. </dependency>
  40. <dependency>
  41. <groupId>com.hazelcast</groupId>
  42. <artifactId>hazelcast</artifactId>
  43. </dependency>
  44. <!-- 将管理服务器声明为客户端,用于自我监控 -->
  45. <dependency>
  46. <groupId>de.codecentric</groupId>
  47. <artifactId>spring-boot-admin-starter-client</artifactId>
  48. <version>2.2.2</version>
  49. </dependency>
  50. <dependency>
  51. <groupId>org.springframework.boot</groupId>
  52. <artifactId>spring-boot-starter-test</artifactId>
  53. <scope>test</scope>
  54. <exclusions>
  55. <exclusion>
  56. <groupId>org.junit.vintage</groupId>
  57. <artifactId>junit-vintage-engine</artifactId>
  58. </exclusion>
  59. </exclusions>
  60. </dependency>
  61. <dependency>
  62. <groupId>org.springframework.security</groupId>
  63. <artifactId>spring-security-test</artifactId>
  64. <scope>test</scope>
  65. </dependency>
  66. <dependency>
  67. <groupId>junit</groupId>
  68. <artifactId>junit</artifactId>
  69. <version>4.11</version>
  70. <scope>test</scope>
  71. </dependency>
  72. </dependencies>
  73. 有什么想法是什么原因导致的吗?
  74. public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
  75. private final AdminServerProperties adminServer;
  76. public WebSecurityConfig(AdminServerProperties adminServer) {
  77. this.adminServer = adminServer;
  78. }
英文:

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

  1. &lt;dependencies&gt;
  2. &lt;dependency&gt;
  3. &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;
  4. &lt;artifactId&gt;spring-cloud-starter-netflix-eureka-client&lt;/artifactId&gt;
  5. &lt;/dependency&gt;
  6. &lt;dependency&gt;
  7. &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
  8. &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
  9. &lt;/dependency&gt;
  10. &lt;dependency&gt;
  11. &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
  12. &lt;artifactId&gt;spring-boot-starter-security&lt;/artifactId&gt;
  13. &lt;/dependency&gt;
  14. &lt;!--Add login page and logout feature --&gt;
  15. &lt;dependency&gt;
  16. &lt;groupId&gt;de.codecentric&lt;/groupId&gt;
  17. &lt;artifactId&gt;spring-boot-admin-starter-server&lt;/artifactId&gt;
  18. &lt;version&gt;2.2.2&lt;/version&gt;
  19. &lt;/dependency&gt;
  20. &lt;dependency&gt;
  21. &lt;groupId&gt;de.codecentric&lt;/groupId&gt;
  22. &lt;artifactId&gt;spring-boot-admin-server&lt;/artifactId&gt;
  23. &lt;version&gt;2.2.2&lt;/version&gt;
  24. &lt;/dependency&gt;
  25. &lt;dependency&gt;
  26. &lt;groupId&gt;de.codecentric&lt;/groupId&gt;
  27. &lt;artifactId&gt;spring-boot-admin-server-ui&lt;/artifactId&gt;
  28. &lt;version&gt;2.2.2&lt;/version&gt;
  29. &lt;/dependency&gt;
  30. &lt;!--Add login page and logout feature --&gt;
  31. &lt;dependency&gt;
  32. &lt;groupId&gt;de.codecentric&lt;/groupId&gt;
  33. &lt;artifactId&gt;spring-boot-admin-server-ui-login&lt;/artifactId&gt;
  34. &lt;version&gt;1.5.7&lt;/version&gt;
  35. &lt;/dependency&gt;
  36. &lt;dependency&gt;
  37. &lt;groupId&gt;com.hazelcast&lt;/groupId&gt;
  38. &lt;artifactId&gt;hazelcast&lt;/artifactId&gt;
  39. &lt;/dependency&gt;
  40. &lt;!--declare the admin server as a client, for self monitoring --&gt;
  41. &lt;dependency&gt;
  42. &lt;groupId&gt;de.codecentric&lt;/groupId&gt;
  43. &lt;artifactId&gt;spring-boot-admin-starter-client&lt;/artifactId&gt;
  44. &lt;version&gt;2.2.2&lt;/version&gt;
  45. &lt;/dependency&gt;
  46. &lt;dependency&gt;
  47. &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
  48. &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
  49. &lt;scope&gt;test&lt;/scope&gt;
  50. &lt;exclusions&gt;
  51. &lt;exclusion&gt;
  52. &lt;groupId&gt;org.junit.vintage&lt;/groupId&gt;
  53. &lt;artifactId&gt;junit-vintage-engine&lt;/artifactId&gt;
  54. &lt;/exclusion&gt;
  55. &lt;/exclusions&gt;
  56. &lt;/dependency&gt;
  57. &lt;dependency&gt;
  58. &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
  59. &lt;artifactId&gt;spring-security-test&lt;/artifactId&gt;
  60. &lt;scope&gt;test&lt;/scope&gt;
  61. &lt;/dependency&gt;
  62. &lt;dependency&gt;
  63. &lt;groupId&gt;junit&lt;/groupId&gt;
  64. &lt;artifactId&gt;junit&lt;/artifactId&gt;
  65. &lt;version&gt;4.11&lt;/version&gt;
  66. &lt;scope&gt;test&lt;/scope&gt;
  67. &lt;/dependency&gt;
  68. &lt;/dependencies&gt;

any idea what is the cause?

public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

  1. private final AdminServerProperties adminServer;
  2. public WebSecurityConfig(AdminServerProperties adminServer) {
  3. this.adminServer = adminServer;
  4. }

答案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:

确定