我刚开始弹跳,每当我尝试运行弹簧启动主脚本时都会收到错误消息。
***************************
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);
}
}
任何线索都可以帮我解决这个问题?为什么它没能开始。
答案 0 :(得分:0)
我在application.properties中获得了错误的值。
Before:
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect;
After:
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
还删除了@Entity注释。
现在工作正常。