目录结构如上图所示,请问我应该怎么配置使用,扫描包需要配置子目录吗?
启动异常如下,求大神指点:
Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2017-10-20 09:19:48.906 ERROR 13288 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
APPLICATION FAILED TO START
Description:
Parameter 0 of constructor in org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration required a bean of type 'javax.sql.DataSource' that could not be found.
- Bean method 'dataSource' not loaded because @ConditionalOnProperty (spring.datasource.jndi-name) did not find property 'jndi-name'
- Bean method 'dataSource' not loaded because @ConditionalOnBean (types: org.springframework.boot.jta.XADataSourceWrapper; SearchStrategy: all) did not find any beans
Action:
Consider revisiting the conditions above or defining a bean of type 'javax.sql.DataSource' in your configuration.
都说了不采用 继承JpaRepository,网上全是继承 JpaRepository教程,这个我知道,有大神指教下吗?
题主你的sql写错了,,,我试了一下,,可以这样查,,
@PersistenceContext
private EntityManager entityManager;
@Test
public void finAllUserNum() {
String hql = "select id,name,num,other_str from user_num";
Query query = entityManager.createQuery(hql);
List<UserNum> testEntities = query.getResultList();
}
【注意】,,select 后面的字段要和Entity,的属性对应,,
有问题还可以追问。。我刚刚测了完美通过
已解决,是maven下载的jar有问题,可能网络不好,重新再springboot官网导入相同版本项目,发现好几个jar存在却报错,删除了重新maven update,另外实体类主键写错了,话你是不细心@Entity
@Table(name = "t_test")
http://www.cnblogs.com/it you know /p/5891443.html