【发布时间】:2015-06-28 05:39:24
【问题描述】:
嗨,我已经按照https://github.com/spring-projects/spring-data-examples/tree/master/rest/headers 配置了我的应用程序,但是当我检查对我的实体的响应时,即使我已经正确设置了所有内容,最后修改的标头也不会出现。 下面的代码 领域类
@Data
@Entity(name = "SHORES_TBL")
@EntityListeners(AuditingEntityListener.class)
public class Shores {
@EmbeddedId
private ShoresKey key;
/* some fields */
@ManyToOne
@MapsId("shoreId")
@JoinColumn(name = "shore_id", columnDefinition = "varchar2(12)")
private Fund fund;
private @JsonIgnore @LastModifiedDate Date updTs;
}
spring boot 应用配置
@SpringBootApplication
// Explicitly enable entity links as Boot fails to auto-configure them
@EnableEntityLinks
@EnableJpaAuditing
public class Services extends SpringBootServletInitializer {
/**
some config
**/
public static void main(String[] args) {
SpringApplication.run(Services.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(Services.class);
}
}
但在测试用例中我没有得到 LAST_MODIFIED 标头
MockHttpServletResponse response = mvc.perform(get(uri)).//
andDo(print()).//
andReturn().getResponse();
pom 配置
<properties>
<spring-data-releasetrain.version>Gosling-BUILD-SNAPSHOT</spring-data-releasetrain.version>
<spring.version>4.2.0.RC1</spring.version>
<java.version>1.8</java.version>
<spring-hateoas.version>0.18.0.BUILD-SNAPSHOT</spring-hateoas.version>
<json-path.version>1.2.0</json-path.version>
</properties>
知道我在这里缺少什么,updTs 在数据库中,并作为更新的时间戳填充。
【问题讨论】:
标签: spring spring-data-jpa spring-data-rest