我在使用@CreatedDate
其他审计功能时遇到了一些问题。我相信我已遵循参考文档中提供的指导,但我相信可能缺少某些内容。我目前正在使用使用 SDN 5.0.2 的 Spring Boot 2.0.0.M7。我正在尝试一个非常简单的示例,但无论我是否使用Long
, LocalDate
,甚至Date
当我在 Neo4j 浏览器中查看数据或尝试将保存的节点加载回 POJO 时,我都不会填充它。
这是我的对象的片段:
@NodeEntity
public class Person {
@Id @GeneratedValue private Long id;
@CreatedBy
private String user;
@CreatedDate
public Long createdDate;
private String name;
public Person() {
}
public Person(String name) {
this.name = name;
}
我有一个非常简单的存储库,它只有一个findByName
方法,主应用程序也没有做太多,但它看起来像这样:
@SpringBootApplication
@EnableNeo4jRepositories
public class Application {
private final static Logger log = LoggerFactory.getLogger(Application.class);
public static void main(String[] args) throws Exception {
SpringApplication.run(Application.class, args);
}
@Bean
CommandLineRunner demo(PersonRepository personRepository) {
return args -> {
personRepository.deleteAll();
Person bob = new Person("Bob");
personRepository.save(bob);
Person bob2 = personRepository.findByName(bob.getName());
log.info("Name: " + bob2.getName() + " Created Date: " + bob2.createdDate);
};
}
}
日志的输出显示createdDate
仍然是null
:
Name: Bob Created Date = : null
我什至创建了一个实现的类AuditorAware
,但应用程序从未触发该代码。我想我缺少一些注释并尝试过@EnableNeo4jAuditing
,但这会导致The dependencies of some of the beans in the application context form a cycle:
我似乎无法找到我所缺少的。我在 SDN 4 中看到有人设置了应用程序侦听器,但那是在审计支持之前。我觉得我已经完成了我的研究,但我已经碰壁了。