Tag: spring data

启动Spring应用程序时出错:bean的初始化失败; 嵌套exception是AbstractMethodError

我有一个使用Spring MVC,Spring Security和Spring Data的Spring应用程序。 一切都过去完美无缺,直到我将Spring Data的版本从1.9.0.RELEASE更新为1.9.0.RELEASE 这是无法创建的存储库bean(BeanCreationException): @Repository // Enables exception translation public interface UsuarioRepository extends CrudRepository { @Query(“SELECT u FROM Usuario u WHERE LOWER(u.login) = LOWER(:login)”) Usuario findByLogin(@Param(“login”) String login); @Query(value = “SELECT * FROM Usuario WHERE fl_ativo = true”, nativeQuery = true) Iterable findAllActives(); } 这是pom.xml (Maven): 4.0.0 br.com.nooder portal-jstl 0.0.1-SNAPSHOT war 2.8.2 […]

spring数据动态地组成@query查询

我有一种情况,我必须在某些方法中@Query JPQL查询,然后将此查询传递给spring数据查询方法,以用作@Query注释中的查询 @Query(value = “:DyanamicQuery”) List filterConfigurPrizeInsurance(String DyanamicQuery); 或者至少是条件部分 @Query(value = “SELECT c FROM PrizeInsuranceConfiguration c WHERE :DyanamicConditions”) List filterConfigurPrizeInsurance(String DyanamicConditions);

Spring Data配置 – 找不到hibernate.properties

我尝试使用Hibernate内存数据库配置Spring Data,基于此 , 这个答案如下: 但我一遍又一遍地得到: org.hibernate.cfg.Environment中。 HHH000206:找不到hibernate.properties 问题是我不想在properties文件中指定它,因为我以前没有Spring Data我想在xml配置中设置它,就像我基于的答案一样。 我错过了什么吗? 提前感谢您的帮助。

Grails @Autowire在Java类中无法正常工作

我有一些Java代码,我想变成一个Bean,可以通过dependency injection在Grails控制器和服务中使用。 代码基于此处 (在作为独立Java应用程序运行时可以正常工作)。 具体来说,我有: // WannabeABeanDB.java package hello; import org.neo4j.graphdb.GraphDatabaseService; import org.neo4j.graphdb.Transaction; import org.neo4j.graphdb.factory.GraphDatabaseFactory; import org.neo4j.kernel.impl.util.FileUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.data.neo4j.config.EnableNeo4jRepositories; import org.springframework.data.neo4j.config.Neo4jConfiguration; import org.springframework.data.neo4j.core.GraphDatabase; import java.io.File; @Component @Configuration @EnableNeo4jRepositories(basePackages = “hello”) public class WannabeABeanDB extends Neo4jConfiguration { public WannabeABeanDB() { setBasePackage(“hello”); } @Bean GraphDatabaseService graphDatabaseService() { return new GraphDatabaseFactory().newEmbeddedDatabase(“accessingdataneo4j.db”); } […]

Spring Data REST不包括资源中的实体链接

由Oliver Gierke解决方案解决 看起来这是Spring 4.2.0中的已知错误,升级到4.2.1提供了预期的function 原始问题 我正在努力将我的开发团队转移到Spring + WebMVC + Data-REST + Data-JPA + Spring HATEOAS for web applications。 我目前的应用程序只是维护我们正在进行的应用程序列表。 我遇到了我的默认Spring Data REST设置问题。 我的资源不包括其特定视图中的链接资源,而它们包含在集合视图中。 我不确定这是否是预期的行为,所以我将在本文末尾包括相关的配置等。 jv.local是我的开发框,apps-list / app是spring-data-rest绑定的地方(下面包含配置) 例: curl jv.local:8080/apps-list/app/departments 返回: { “_links” : { “self” : { “href” : “http://jv.local:8080/apps-list/app/departments{?page,size,sort}”, “templated” : true } }, “_embedded” : { “departments” : [ { “name” : […]

Spring Data Data中的分页用于嵌套资源

访问以下url时,我会得到分页作为回应 /api/userPosts/ { “_links” : { “self” : { “href” : “/api/userPosts{?page,size,sort}”, “templated” : true }, “next” : { “href” : api/userPosts?page=1&size=20{&sort}”, “templated” : true } }, “_embedded” : { “userPosts” : [ { … 但是,在访问以下URL时,Spring Data REST没有开箱即用的分页 – /api/users/4/userPosts { “_embedded” : { “userPosts” : [ { UserRepository和UserPostRepository都是具有分页的JPARepository。 因此,第二个URL导致GC开销超出错误,因为返回的结果的行数很大。 @RepositoryRestResource(excerptProjection = UserProjection.class) public interface […]

单个自定义序列化程序,用于所有嵌入的带注释的对象,用它们的id替换它们

我有这样的实体: @Entity public Product { @Id public int id; public String name; @ManyToOne(cascade = {CascadeType.DETACH} ) Category category @ManyToMany(cascade = {CascadeType.DETACH} ) Set secondaryCategories; } 和 @Entity public Category { @Id public int id; public String name; @JsonCreator public Category(int id) { this.id = id; } public Category() {} } 是否可以使用注释来注释Category类或category和secondaryCategories属性,这些注释将它们序列化为嵌入时的ID。 现在,当我为id = 1的产品进行GET时,我从服务器获取: { […]

使用Spring Data在$ project MongoDB中使用$ filter

我有一个子文档,它是父文档的数组。 “设备” 在那个数组中,我有一个属性是Date属性。 我想通过确定的日期找到包含子子文档的父文档,如下所示: { “_id” : ObjectId(“5818fa596969a1339093a7da”), “fecha” : ISODate(“2016-11-01T05:00:00.000Z”), “spot” : “5808e3926969a126c8365c94”, “devices” : [ { “evaluationDate” : ISODate(“2016-11-01T20:26:00.000Z”), “seenTimesCounter” : 0, “category” : “PRE_PASAJERO”, “status” : “NO_CONECTADO” }, { “evaluationDate” : ISODate(“2016-11-01T20:26:00.000Z”), “seenTimesCounter” : 0, “category” : “PRE_PASAJERO”, “status” : “NO_CONECTADO” }, { “evaluationDate” : ISODate(“2016-11-01T20:26:00.000Z”), “seenTimesCounter” : 0, “category” : “PRE_PASAJERO”, […]

Spring CrudRepository在自定义查询方法定义上抛出AbstractMethodError

我正在尝试在扩展CrudRepository接口的接口中创建自定义查询。 不幸的是,每次收到java.lang.AbstractMethodError时都会出于某些原因。 请参阅下面的完整堆栈跟踪。 据我所知,问题是Spring框架应该“神奇地”为我的方法声明创建一个实现,但由于某种原因它没有成功。 存储库界面: public interface PresentationRepository extends CrudRepository { Iterable findAll(Sort sort); Page findAll(Pageable pageable); List findByTitle(String title); // the problematic line } 演示实体课程: @Entity @Table(name = “presentation”) public class Presentation { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = “presentation_id”) Integer id; String title; String logo; @Column(name = “length”) Integer interval; @Column(name = “pages”) […]

如何在jpa查询中使用自定义函数?

我是Spring Jpa和Hibernate的新手。 我试图从Oracle数据库使用自定义函数获取数据。 我可以定义一个实体及其相关的服务,实现和存储库。 另外,我使用registerFunction创建了一个新的自定义Oracle方言,如下所示。 所以我有两个问题: 1)在我的Oracle数据库中,该函数位于不同的模式下。 我需要指定其架构吗? 如果是这样的话? 或者hibernate会自动找到它吗? 在提供完整的堆栈跟踪之后,我将在本文末尾询问我的第二个问题… 这是我的完整堆栈跟踪: MyOracle10gDialect package blog; import org.hibernate.dialect.Oracle10gDialect; import org.hibernate.dialect.function.StandardSQLFunction; public class MyOracle10gDialect extends Oracle10gDialect { public MyOracle10gDialect() { super(); registerFunction(“my_function”, new StandardSQLFunction(“my_function”)); } } application.properties … spring.jpa.database-platform=blog.MyOracle10gDialect … 实体: package blog.models; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.Table; @Entity @Table(name = “item”, schema = […]