gpt4 book ai didi

java - 如何解决启动ApplicationContext时出错

转载 作者:行者123 更新时间:2023-12-02 09:42:55 29 4
gpt4 key购买 nike

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-07-07 12:52:59.026 ERROR 10816 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :

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

Description:

Field authorDao in com.Jpa.Library.libraryItem.LibraryItemApplication required a bean of type 'com.Jpa.Library.libraryItemDao.AuthorDao' 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 'com.Jpa.Library.libraryItemDao.AuthorDao' in your configuration.

这是我的代码:

package com.Jpa.Library.libraryItem;
import javax.transaction.Transactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import com.Jpa.Library.libraryItemDao.AuthorDao;
import com.Jpa.Library.libraryItemDao.LibraryItemDao;
import com.Jpa.Library.libraryItemDao.RackDao;
import com.Jpa.Library.libraryItemDao.RackItemDao;
import com.Jpa.Library.libraryItemEntity.LibraryItem;

@SpringBootApplication
public class LibraryItemApplication implements ApplicationRunner{

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

@Autowired
private AuthorDao authorDao;

@Autowired
private LibraryItemDao libraryItemDao;

@Autowired
private RackDao rackDao;

@Autowired
private RackItemDao rackItemDao;

@Override
@Transactional
public void run(ApplicationArguments args) throws Exception {
LibraryItem libraryitem = libraryItemDao.findByTitle("Fifty Shades of Gray");
System.out.println(libraryitem);
}
}

最佳答案

A) 仔细阅读错误消息

B) “考虑在您的配置中定义“com.Jpa.Library.libraryItemDao.AuthorDao”类型的 bean。”

关于java - 如何解决启动ApplicationContext时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56919822/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com