【问题标题】:spring data rest last modified header not getting populatedspring data rest last modified header 未填充
【发布时间】: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


    【解决方案1】:

    它终于奏效了,似乎我使用了错误的版本,切换到了 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>
    

    【讨论】:

      猜你喜欢
      • 2011-07-16
      • 2011-02-02
      • 2011-08-25
      • 1970-01-01
      • 2018-03-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-16
      相关资源
      最近更新 更多