我最近升级到了新的Eclipse版本(Oxygen).我从网站上下载了lombok.jar并安装了它.这是eclipse.ini安装后的样子:
-startup
plugins/org.eclipse.equinox.launcher_1.4.0.v20161219-1356.jar
--launcher.library
C:\Users\xxx\.p2\pool\plugins\org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.500.v20170531-1133
-product
org.eclipse.epp.package.jee.product
-showsplash
org.eclipse.epp.package.common
--launcher.defaultAction
openFile
--launcher.appendVmargs
-vmargs
-Dosgi.requiredJavaVersion=1.8
-Dosgi.instance.area.default=@user.home/eclipse-workspace
-XX:+UseG1GC
-XX:+UseStringDeduplication
-Dosgi.requiredJavaVersion=1.8
-Xms256m
-Xmx1024m
-Declipse.p2.max.threads=10
-Doomph.update.url=http://download.eclipse.org/oomph/updates/milestone/latest
-Doomph.redirection.index.redirection=index:/->http://git.eclipse.org/c/oomph/org.eclipse.oomph.git/plain/setups/
-javaagent:lombok.jar
Run Code Online (Sandbox Code Playgroud)
我可以使用Lombok,如下所示:
但是当在其他类中使用getter/setter和/或构造函数时,我得到了这个错误:
这些是我的Eclipse和Lombok版本:
Eclipse Java EE IDE for Web Developers.
Version: Oxygen Release (4.7.0)
Build id: 20170620-1800
Lombok v1.16.18 "Dancing Elephant" is installed. https://projectlombok.org/
Run Code Online (Sandbox Code Playgroud)
谁知道我怎么解决它?
虽然我喜欢lombok,但有时在配置时会出现太多问题,特别是在Linux中.当我尝试安装它时,我收到以下错误:
我尝试手动设置它,如 https://github.com/rzwitserloot/lombok/issues/95所示, 但这也没有用.有什么建议?
我的项目有问题.它是一个Spring CRUD RestFul API,它公开了提供Json数据的服务.我使用JDK-7,Eclipse-Neon和Maven来编码,构建并将项目部署到JBossEAP 6.4服务器中.每件事都运作良好,服务正确响应.
所以我决定添加Lombok,以减少锅炉代码并提高代码的可读性.顺便说一下,我之前在另一个项目中使用了龙目岛,并且运行良好.
这是我的问题,包括Lombok后: - 当我使用Maven(mvn clean install)时,一切顺利,项目部署并且工作完全正常. - 当项目由Eclipse构建时,Lombok注释(即:@Data等)不包含在*.class中.因此Eclipse部署的耳朵工作正常但是所有实体都没有任何getter/setter等等.
我知道Eclipse配置正确,因为我的代码上没有任何关于Lombok的警告,eclipse的大纲视图显示了我生成的方法.
有没有人对这类问题有所了解?
我用 Spring Boot 实现了 Rest api。在我的控制器类中,我有代码来处理 GET 请求,如果找到记录,该请求将返回 JSON。
// SeqController.java
@Autowired
private SeqService seqService;
@RequestMapping(
value = "/api/seqs/{analysis_id}",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<SeqTb>> getSeqByAnalysisId(@PathVariable("analysis_id") String analysis_id) {
List<SeqTb> seqs = seqService.findByAnalysisId(analysis_id);
return new ResponseEntity(seqs, HttpStatus.OK);
}
Run Code Online (Sandbox Code Playgroud)
我还创建了一个SeqServiceBean扩展接口的 bean 类SeqService,该接口又调用以下 JPA 存储库中的方法进行查询。
//SeqRepository.java
@Repository
public interface SeqRepository extends JpaRepository<SeqTb, Integer> {
@Override
public List<SeqTb> findAll();
public List<SeqTb> findByAnalysisId(String analysisId);
}
Run Code Online (Sandbox Code Playgroud)
问题是当我在浏览器中输入网址(http://localhost:8080/api/seqs/fdebfd6e-d046-4192-8b97-ac9f65dc2009)时,它只返回一对空括号。我刚刚查了一下数据库,确实有这条记录。我做错了什么?