代码之家  ›  专栏  ›  技术社区  ›  prity sinha

不鼓励依赖循环引用,在spring boot中默认情况下禁止使用循环引用

  •  1
  • prity sinha  · 技术社区  · 3 年前

    我在运行spring boot应用程序时收到以下错误消息。

    Description:
    
    The dependencies of some of the beans in the application context form a cycle:
    
    ┌─────┐
    |  securityConfiguration (field private com.prity.springbootdemo1.service.UserService com.prity.springbootdemo1.config.SecurityConfiguration.userService)
    ↑     ↓
    |  userServiceImpl (field private org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder com.prity.springbootdemo1.service.UserServiceImpl.passwordEncoder)
    └─────┘
    
    
    Action:
    
    Relying upon circular references is discouraged and they are prohibited by default. Update your application to remove the dependency cycle between beans. As a last resort, it may be possible to break the cycle automatically by setting spring.main.allow-circular-references to true.
    
    1 回复  |  直到 3 年前
        1
  •  1
  •   RAMAN PRAKASH VERMA    3 年前
    spring.main.allow-circular-references=true
    

    在应用程序中添加上述行。属性文件,它将正常运行。