[英]Failed to execute spring boot application
我是spring的新手,每當我嘗試運行spring boot main腳本時,都會收到以下錯誤消息。
***************************
APPLICATION FAILED TO START
***************************
Description:
Field testrepo in com.online.XXX.app.dao.TestDAO required a bean
named 'entityManagerFactory' that could not be found.
Action:
Consider defining a bean named 'entityManagerFactory' in your configuration.
以下是我的DAO課程:
@Service
public class TestDAO
{
@Autowired
private TestRep testrepo;
public List<E2ETestsDTO> finaAll() {
return testrepo.findAll();
}
}
我有如下的pojo課:
@Entity
@Table(name = "testXXX")
@EntityListeners(AuditingEntityListener.class)
public class E2ETestsDTO
{
@NotBlank
private String test_id;
@NotBlank
private String test_name;
public String getTest_id()
{
return test_id;
}
public void setTest_id(String test_id)
{
this.test_id = test_id;
}
public String getTest_name()
{
return test_name;
}
public void setTest_name(String test_name)
{
this.test_name = test_name;
}
}
以下是jpa存儲庫:
@Repository
public interface TestRep extends JpaRepository<E2ETestsDTO, Long>
{
}
下面是控制器類文件:
@RestController
@RequestMapping("/amzonrunner")
public class TestController
{
@Autowired
TestDAO testdao;
@GetMapping("/sample")
public List<E2ETestsDTO> getAllTestRecords()
{
return testdao.finaAll();
}
}
下面是主要代碼:
@SpringBootApplication
@EnableJpaAuditing
//@EnableJpaRepositories("com.online.xxx.app")
public class TestApplication
{
public static void main(String args[])throws Exception
{
SpringApplication.run(TestApplication.class);
}
}
有任何線索可以幫助我解決此問題嗎? 為什么它無法啟動。
在application.properties中給了我錯誤的值。
Before:
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect;
After:
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
還刪除了@Entity批注。
現在工作正常。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.