当前位置: 首页 > 知识库问答 >
问题:

Spring BeanCreationException错误

干照
2023-03-14

我在研究STS数据库连接。

我试着和我当地的数据库联系。

@Controller
public class HomeController {

@Autowired private AccountRepository AccountRepository;

//@Autowired
//private AccountDaoImpl AccountDaoImpl;

//private AccountDao AccountDao;

@RequestMapping(value = "/", method = RequestMethod.GET)
public String home(Locale locale, Model model) {
    return "home";
}

@RequestMapping(value = "/home", method = RequestMethod.GET)
public String homehome(Locale locale, Model model) {
    return "home";
}
@RequestMapping(value = "/login", method = RequestMethod.POST)
public @ResponseBody List<Account> getUserList() {

    return AccountRepository.findAll();
    //EntityManagerFactory emf = Persistence.createEntityManagerFactory("NewPersistenceUnit");
    //AccountDaoImpl.entityManager = emf.createEntityManager();
    //return AccountDaoImpl.getAccount();
}
//@RequestMapping(value = "/login", method = RequestMethod.POST)
//public String login(Locale locale, Model model) {
//  
//  EntityManagerFactory emf = Persistence.createEntityManagerFactory(
//  return "login";
//}
}
@Service
public interface AccountRepository extends JpaRepository<Account, Long> {
}
 @Entity
 @Table(name = "Account")
 public class Account implements Serializable {
 @Id
 @Column(name = "email")
 private String email;
 @Column(name = "id")
 private String id;
 @Column(name = "password")
 private String password;

 public void setEmail(String email) {
     this.email = email;
 }

 public String getEmail() {
     return email;
 }

 public String getId() {
     return id;
 }

 public void setId(String id) {
     this.id = id;
 }

 public String getPassword() {
     return password;
 }

 public void setPassword(String password) {
     this.password = password;
 }

类型异常报告

servlet的消息servlet.init()appServlet引发异常

说明服务器遇到一个内部错误,使其无法满足此请求。

我想避免这个错误。

我该怎么办?

共有1个答案

荆梓
2023-03-14

根大小写是:“没有找到com.myongjoon.spring.AccountRepository类型的合格bean”。

这是因为,您的代码看起来像是试图为存储库使用Spring-Data-Jpa。但这需要:

>

  • 您的存储库只是一个接口(没有@service注释)和
  • 您需要通过以下方式启用Spring-Data-Jpa

      null

    @见:Spring-Data-Jpa参考

  •  类似资料:
    • 我正在尝试搜索亚马逊的产品广告,并使用botlenose来帮助我做到这一点。但是,我刚刚收到HTTP错误400。 其他一些重要信息: 我来自巴西,我的标签也来自亚马逊。这是个问题吗? 我确实检查了我的钥匙、秘密和标签,一切正常。我确实在StackOverflow上查看了其他一些问题,但对我来说没有任何效果。 当然,出于安全原因,我更改了密钥。 Traceback(最近一次调用最后一次):File"

    • 我有一个基于Spring Web model view controller(MVC)框架的项目。Spring Web模型-视图-控制器(MVC)框架的版本是3.2.8 我有这个控制器 这个URL一切正常:

    • 目前从Angular JS controller中,我试图将JSON数据发送到后端服务。但是我有400个错误的请求错误。 在Controller中,我试图通过http服务发送数据,如下所示:

    • 我得到了这个错误,有什么想法会导致它吗?我试图发送一个DTO,它有一个扩展抽象类的对象列表,我想这个问题可能是因为DTO中的列表,还是因为抽象类的子类?

    • 在月食中, ”org.apache.axis2。AxisFault:传输错误: 403错误:禁止”试图从svn检出项目时发生错误。我不能实现这个错误,因此我检查了从终端使用"svn-co"命令的项目。 但是,有趣的是,当我试图在Eclipse中运行应用程序时,在输入凭据(用户名和密码)并按下“登录”按钮之后,我又遇到了相同的错误。响应是JFrame上的无效用户名/密码,但凭据没有错误。这只发生在日

    • Errors 错误 Library routines must often return some sort of error indication to the caller. As mentioned earlier, Go’s multivalue return makes it easy to return a detailed error description alongside th

    • 本章概述了Google API错误模型,以及开发人员如何正确生成和处理错误的一般指南。 Google API使用简单的协议无关错误模型,这使我们能够在不同的API,API协议(如gRPC或HTTP)以及错误上下文(例如,异步,批处理或工作流错误)中获得一致的体验。 错误模型 错误模型在逻辑上由google.rpc.Status定义,当API发生错误时,返回一个Status实例给客户端。 以下代码段

    • 5.4. 错误 在Go中有一部分函数总是能成功的运行。比如strings.Contains和strconv.FormatBool函数,对各种可能的输入都做了良好的处理,使得运行时几乎不会失败,除非遇到灾难性的、不可预料的情况,比如运行时的内存溢出。导致这种错误的原因很复杂,难以处理,从错误中恢复的可能性也很低。 还有一部分函数只要输入的参数满足一定条件,也能保证运行成功。比如time.Date函数