Java Xtend';s#U字段命名和SpringData';s存储库命名约定
Xtend和Spring数据之间的命名约定似乎不兼容 例如:Java Xtend';s#U字段命名和SpringData';s存储库命名约定,java,spring-data,xtend,Java,Spring Data,Xtend,Xtend和Spring数据之间的命名约定似乎不兼容 例如: // User.xtend class User { @Property var Long id; } interface UserRepository extends JpaRepository<User> { public User findById(Long id) } //User.xtend 类用户{ @财产 var长id; } 接口UserRepository扩展了JpaRe
// User.xtend
class User {
@Property
var Long id;
}
interface UserRepository extends JpaRepository<User> {
public User findById(Long id)
}
//User.xtend
类用户{
@财产
var长id;
}
接口UserRepository扩展了JpaRepository{
公共用户findById(长id)
}
@Property
注释将id
重命名为\u id
,这会导致Spring数据失败,声称未找到属性id
有没有办法:
- 抑制Xtend对字段的重命名
- “教授”有关命名约定的Spring数据(查找字段?添加下划线)
- 指示Spring数据使用属性访问,而不是属性解析的字段访问
我相信,任何这些都可以解决这个问题。自2.7.3以来,@Property注释已被@Accessors取代,它不再在字段前面加下划线 在2.7.3之前,您必须构建自己的@Property注释,该注释不会在字段名称前加下划线 看
(更新)我只想指出,
@属性
注释已被弃用,并被@访问器
取代。我还发现了这篇关于编写活动注释的最佳实践的文章。