程序问答   发布时间:2022-06-02  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了Spring Boot CrudRepo定义一个bean大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

如何解决Spring Boot CrudRepo定义一个bean?

开发过程中遇到Spring Boot CrudRepo定义一个bean的问题如何解决?下面主要结合日常开发的经验,给出你关于Spring Boot CrudRepo定义一个bean的解决方法建议,希望对你解决Spring Boot CrudRepo定义一个bean有所启发或帮助;

您的@H_828_3@main课程很可能是在一个包中定义的,而其他包没有被扫描。

尝试使用以下方法注释您的@H_828_3@main班级:

@ComponentScan("com.projectWS")

根据您的错误消息判断,并假设您的软件包级别的顶部从 com.projectWS

解决方法

我在Spring Boot中有一个关于存储库的问题。我有服务:

@service("userservice")
public class UserserviceImpl implements Userservice {

  @Autowired
  private UserRepository userRepository;

  @Autowired
  private RoleRepository roleRepository;
}

和这里的回购:

@Repository("userRepository")
public interface UserRepository extends CrudRepository<User,Long> {
     User findByEmail(String email);
}

当我运行该应用程序时,我收到以下消息:

Description:

Field userRepository in com.projectWs.service.UserserviceImpl required a 
bean of type 'com.projectWs.repo.UserRepository' that could not be found.

Action:

Consider defining a bean of type 'com.projectWs.repo.UserRepository' in your 
configuration.

请帮助我,我很拼命&Hellip;这是我的主要课程:

@SpringBootApplication
@Configuration
@EnableWebMvc
public class Main {

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

另一个问题是,@EnableJpaRepositories没有得到认可!

大佬总结

以上是大佬教程为你收集整理的Spring Boot CrudRepo定义一个bean全部内容,希望文章能够帮你解决Spring Boot CrudRepo定义一个bean所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。