小编ole*_*exd的帖子

Eclipse Mars + lombok +保存动作

我使用Eclipse Mars(全新安装,版本:Mars Release 4.5.0,build id:20150621-1200)并安装了lombok v.1.16.4时遇到问题.

保存时我收到错误,如果激活了"保存操作"并启用了Java源代码格式化程序(首选项 - > Java - >编辑器 - >保存操作 - >"格式化源代码").这是一条错误消息:

A save participant caused problems. The save participant 'Code Clean Up' caused an exception: java.lang.ArrayIndexOutOfBoundsException: -1. See the error log for details.
Run Code Online (Sandbox Code Playgroud)

和eclipse错误日志视图中的堆栈跟踪:

java.lang.ArrayIndexOutOfBoundsException: -1
at java.util.ArrayList.elementData(Unknown Source)
at java.util.ArrayList.get(Unknown Source)
at org.eclipse.jdt.internal.formatter.TokenManager.get(TokenManager.java:68)
at org.eclipse.jdt.internal.formatter.TokenManager.findIndex(TokenManager.java:161)
at org.eclipse.jdt.internal.formatter.TokenManager.lastIndexIn(TokenManager.java:198)
at org.eclipse.jdt.internal.formatter.LineBreaksPreparator.handleBracedCode(LineBreaksPreparator.java:544)
at org.eclipse.jdt.internal.formatter.LineBreaksPreparator.visit(LineBreaksPreparator.java:247)
at org.eclipse.jdt.core.dom.MethodDeclaration.accept0(MethodDeclaration.java:611)
at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2711)
at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2782)
at org.eclipse.jdt.core.dom.TypeDeclaration.accept0(TypeDeclaration.java:470)
at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2711)
at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2782)
at org.eclipse.jdt.core.dom.CompilationUnit.accept0(CompilationUnit.java:212)
at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2711)
at org.eclipse.jdt.internal.formatter.DefaultCodeFormatter.prepareLineBreaks(DefaultCodeFormatter.java:356)
at org.eclipse.jdt.internal.formatter.DefaultCodeFormatter.prepareFormattedCode(DefaultCodeFormatter.java:194)
at org.eclipse.jdt.internal.formatter.DefaultCodeFormatter.format(DefaultCodeFormatter.java:155)
at …
Run Code Online (Sandbox Code Playgroud)

java eclipse lombok

9
推荐指数
1
解决办法
2664
查看次数

imap 不允许使用 gmail 文件夹 - mail.select “收件箱”以外的文件夹

基本上如标题所述,我正在使用

mail.select("inbox")
result, data = mail.search(None, "ALL")
ids = data[0] # data is a list.
id_list = ids.split() # ids is a space separated string
latest_email_id = id_list[-1] # get the latest
Run Code Online (Sandbox Code Playgroud)

从收件箱获取最新的电子邮件。理论上,您可以将“收件箱”更改为 gmail 中的另一个标签或文件夹(我的标签和文件夹使用 mail.list() 就可以显示了)。我想使用我的标签“服务器状态/利维坦”,但它抛出错误

Traceback (most recent call last):
  File "E:\False Apparition\Desktop\test3.py", line 18, in <module>
    mail.select("Server Status/Leviathan")
  File "C:\Users\Ancient Abysswalker\AppData\Local\Programs\Python\Python36-32\lib\imaplib.py", line 737, in select
    typ, dat = self._simple_command(name, mailbox)
  File "C:\Users\Ancient Abysswalker\AppData\Local\Programs\Python\Python36-32\lib\imaplib.py", line 1188, in _simple_command
    return self._command_complete(name, self._command(name, *args))
  File "C:\Users\Ancient Abysswalker\AppData\Local\Programs\Python\Python36-32\lib\imaplib.py", line 1019, in …
Run Code Online (Sandbox Code Playgroud)

python email gmail imap

3
推荐指数
1
解决办法
2219
查看次数

JAXRS 2.0 客户端:FOLLOW_REDIRECTS 属性不起作用

我正在尝试让自动重定向在 Jersey Client 2.0 中工作。这是我的代码:

ClientConfig cc = new ClientConfig().property(ClientProperties.FOLLOW_REDIRECTS, true);
Client c = ClientBuilder.newClient(cc);
WebTarget wt = c.target("some_path");
SystemInfo info = wt.request(MediaType.APPLICATION_XML_TYPE).get(SystemInfo.class);
Run Code Online (Sandbox Code Playgroud)

服务器按预期在位置标头中发送带有另一个 URL 的 HTTP 302。我假设根据Jersey JAXRS 客户端 API,客户端将自动重定向到新的指定 URL,但我收到的是RedirectionException

这是适当的行为吗?如何在不手动在 try-catch-block 中实现重定向的情况下使客户端重定向工作?

提前致谢!


更新:

我发现了奇怪行为的问题点。如果以编程方式在服务器上进行重定向,例如:

return Response.seeOther(another_uri).build();
Run Code Online (Sandbox Code Playgroud)

一切安好。但就我而言,由于部署描述符中的 security-constraint 元素而进行了重定向:

<security-constraint>
    ...
    <user-data-constraint>
        <transport-guarantee>CONFIDENTIAL</transport-guarantee>
    </user-data-constraint>
</security-constraint>
Run Code Online (Sandbox Code Playgroud)

因此,客户端从重定向http:// localhost:8080/some_pathhttps:// localhost:8181/another_path自动servlet容器。在浏览器中它工作正常,但 Jersey 客户端似乎忽略了 FOLLOW_REDIRECTS 属性并抛出一个 RedirectionException 。

在这种情况下是否有机会使重定向正常工作?谢谢!

java rest jax-rs jersey-client

2
推荐指数
1
解决办法
4940
查看次数

带有前缀和可选后缀的正则表达式

这可能是关于SO的正则表达式可选后缀的100 + 1问题,但我没有找到任何,这可以帮助我:(

我需要从常见模式中提取字符串的一部分:

prefix/s/o/m/e/t/h/i/n/g/suffix
Run Code Online (Sandbox Code Playgroud)

使用正则表达式.该前缀是常数和后缀可能不会出现在所有的,所以prefix/(.+)/suffix不符合我的要求.模式prefix/(.+)(?:/suffix)?返回s/o/m/e/t/h/i/n/g/suffix.这部分(?:/suffix)?必须更加贪婪.

我想s/o/m/e/t/h/i/n/g从这些输入字符串中获取:

prefix/s/o/m/e/t/h/i/n/g/suffix
prefix/s/o/m/e/t/h/i/n/g/
prefix/s/o/m/e/t/h/i/n/g
Run Code Online (Sandbox Code Playgroud)

提前致谢!

java regex regex-greedy

2
推荐指数
1
解决办法
3640
查看次数

标签 统计

java ×3

eclipse ×1

email ×1

gmail ×1

imap ×1

jax-rs ×1

jersey-client ×1

lombok ×1

python ×1

regex ×1

regex-greedy ×1

rest ×1