我最近升级到了新的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)
谁知道我怎么解决它?
我有一个这个描述的练习:
1122 produces a sum of 3 (1 + 2) because the first digit (1) matches the second digit and the third digit (2) matches the fourth digit.
1111 produces 4 because each digit (all 1) matches the next.
1234 produces 0 because no digit matches the next.
91212129 produces 9 because the only digit that matches the next one is the last digit, 9.
Run Code Online (Sandbox Code Playgroud)
我写了以下代码:
String inputString = "1111"; // taking this number as example
int sum = 0; …Run Code Online (Sandbox Code Playgroud) 我现在正在寻找如何将调试器附加到 netbeans 中的方法。所以我们有一个 Start.java 类,其中嵌入了码头。类似于这个http://wiki.eclipse.org/Jetty/Tutorial/Embedding_Jetty 所以我通过运行这个 Start.java 文件来启动我的 Web 应用程序。一切正常,直到我想调试为止。我已经看到了多种关于 eclipse 的方法,而我为 netbeans 找到的极少数方法没有帮助。
有人有线索吗?在项目属性中,在操作下,我添加了
Env.MAVEN_OPTS=-Xms512m -Xmx512m -XX:PermSize=128m -XX:MaxPermSize=128m -Xverify:none -Xnoclassgc -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n
在通过 main() 运行文件和通过 main() 调试文件下
当我附加 java 调试器 (jpda) 时,它似乎正在运行,但它忽略了断点
有人知道吗?
提前致谢
我正在研究我的应用程序中的异常处理。在我的服务中我有这个方法:
public Optional<Entity> getEntityById(Long id) {
return Optional.of(EntityMapper.fromEntityToDto(repository
.findById(id)
.orElseThrow(() -> new EntityNotFoundException("No entry was found for" + " id: " + id))));
}
Run Code Online (Sandbox Code Playgroud)
在我的异常处理程序中,我有以下内容
@ControllerAdvice
public class ControllerAdvisor extends ResponseEntityExceptionHandler {
@ExceptionHandler(EntityNotFoundException.class)
public ResponseEntity<Object> handleEntityNotFoundException(EntityNotFoundException ex, WebRequest request) {
ErrorResponse errorResponse = new ErrorResponse(HttpStatus.NOT_FOUND, "Entity not found", ex.getMessage());
return new ResponseEntity<>(errorResponse, HttpStatus.NOT_FOUND);
}
}
Run Code Online (Sandbox Code Playgroud)
我在这里和这里看到过他们这样做的例子,但在我看来,这就像滥用HttpStatus. 该资源是 API 端点(这很好),而不是未找到的实体。处理这个用例的最佳方法是什么?
根据 IQbrod 的回答,我创建了一个例外:
@ResponseStatus(value = HttpStatus.NO_CONTENT)
public class MyEntityNotFoundException extends RuntimeException {
public MyEntityNotFoundException(String message) { …Run Code Online (Sandbox Code Playgroud)