spring 上次修改的剩余数据 header 未填充
spring data rest last modified header not getting populated
您好,我已经按照 https://github.com/spring-projects/spring-data-examples/tree/master/rest/headers 配置了我的应用程序,但是当我检查对我的实体的响应时,即使我已经正确设置了所有内容,最后修改的 header 也不会出现。
下面的代码
域 class
@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 启动应用程序配置
@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 header
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 boot 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>
您好,我已经按照 https://github.com/spring-projects/spring-data-examples/tree/master/rest/headers 配置了我的应用程序,但是当我检查对我的实体的响应时,即使我已经正确设置了所有内容,最后修改的 header 也不会出现。 下面的代码 域 class
@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 启动应用程序配置
@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 header
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 boot 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>