您好我已根据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 application config
@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 config
<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在db中并且被填充为更新的时间戳。
答案 0 :(得分:2)
它最终起作用似乎我使用了错误的版本切换到弹簧启动1.3.0.BUILD-SNAPSHOT,现在它就像一个魅力。
使用POM
<dependencyManagement>
<dependencies>
<dependency>
<!-- Import dependency management from Spring Boot -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>1.3.0.BUILD-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>