需要找不到类型的豆

时间:2020-08-04 17:56:13

标签: java spring-boot visual-studio-code spring-repositories

我在项目中做了一些rest api。我有他们的模型,存储库,控制器和服务。他们工作正常,并且My sql server也已经成功创建了所有表。

现在,我正在尝试为我创建了usersauthrole模型的api实现基于角色的授权。这是我要遵循的代码:

https://github.com/TechPrimers/spring-security-db-example

Configuration.java:

//import statements
@EnableGlobalMethodSecurity(prePostEnabled = true)
@EnableJpaRepositories(basePackageClasses = UsersAuthRepository.class)
@EnableWebSecurity
@Configuration
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {

Application.java:

  @SpringBootApplication


 public class Application {

public static void main(String[] args) {
          SpringApplication.run(Application.class, args);
    }
 
}

当我运行我的项目时,它给我这个错误:

APPLICATION FAILED TO START
***************************

Description:

Field BlankRepository in 

required a bean of type 


that could not be found.

The injection point has the following annotations:
    - @org.springframework.beans.factory.annotation.Autowired(required=true)


Action:

Consider defining a bean of type 
'BlankRepository' in 
 your 
 configuration.

现在,这是我在实施授权之前创建的模型之一。该表也存在于sql server中。实施授权后出现此错误。我也有所需的存储库。 我是春季启动的新手,但我认为此错误与

有关
  @EnableJpaRepositories(basePackageClasses = UsersRepository.class)

在我的文件中。也许我的应用程序未读取这些存储库或其他内容。我仍然不太明白这条线的目的,所以有人可以帮助我我所缺少的吗?谢谢!

1 个答案:

答案 0 :(得分:0)

添加注释

 const DUMMY_PLACES = [
      {
        todos: {
          allIds: [1, 2, 3, 4,5],
          byIds: {
            "1": {
              content: "test1",
              completed: false,
            },
            "2": {
              content: "test2",
              completed: false,
            },
            "3": {
              content: "test3\\",
              completed: false,
            },
            "4": {
              content: "test4",
              completed: false,
            },
            "5": {
              content: "test5",
              completed: false,
            },
          },
        },
        visibilityFilter: "all",
      },
    ];

@SpringBootApplication(scanBasePackages={xxx})
相关问题