每次使用Eclipse的Runnable Jar向导,我都可以创建一个可运行的jar。如果我在Eclipse的复选框中选中“另存为ANT脚本”,那么将该代码合并到build.xml中,然后让我们的GitLab CI流程进行构建&创建一个可运行的jar,它运行,但它似乎无法在该jar中找到一个类,即使.class文件在那里。
我不知道从哪里开始。 Eclipse构建中生成的jar文件与独立的java / ant构建类似,但不完全相同。有些事情不合时宜,但这就是我现在可以说的一切。
我怎样才能开始磨练呢?我的程序是Jersey Web客户端。我正在使用Genson,我在独立的jar版本中获得的错误消息是
org.glassfish.jersey.message.internal.MessageBodyProviderNotFoundException: MessageBodyWriter not found for media type=application/json
但是我可以列出jar文件并且都有这些条目
47 Sun Mar 27 22:23:48 CDT 2016 META-INF/services/javax.ws.rs.ext.MessageBodyWriter
1220 Thu Aug 07 14:08:08 CDT 2014 javax/ws/rs/ext/MessageBodyWriter.class
现在我可以通过在Eclipse中构建并手动部署文件来解决这个问题,但当然这是不可接受的。
编辑:感谢一位乐于助人的朋友,我被指出了META-INF /服务的内容。我不知道这意味着什么,但这里有来自两个罐子的内容。GitLab jar (get MessageBodyWriter error message)
0 Sun Mar 27 22:23:48 CDT 2016 META-INF/services/
47 Sun Mar 27 22:23:48 CDT 2016 META-INF/services/javax.json.spi.JsonProvider
47 Sun Mar 27 22:23:48 CDT 2016 META-INF/services/javax.ws.rs.ext.MessageBodyReader
47 Sun Mar 27 22:23:48 CDT 2016 META-INF/services/javax.ws.rs.ext.MessageBodyWriter
47 Sun Mar 27 22:23:48 CDT 2016 META-INF/services/javax.ws.rs.ext.Providers
50 Sun Mar 27 22:23:48 CDT 2016 META-INF/services/org.glassfish.jersey.internal.spi.AutoDiscoverable
61 Fri May 27 19:08:18 CDT 2016 META-INF/services/org.glassfish.hk2.extension.ServiceLocatorGenerator
60 Thu Oct 27 14:32:12 CDT 2016 META-INF/services/org.glassfish.jersey.internal.spi.AutoDiscoverable
67 Thu Oct 27 14:32:12 CDT 2016 META-INF/services/javax.servlet.ServletContainerInitializer
67 Thu Oct 27 14:32:12 CDT 2016 META-INF/services/org.glassfish.jersey.servlet.spi.AsyncContextDelegateProvider
63 Thu Oct 27 14:32:12 CDT 2016 META-INF/services/org.glassfish.jersey.servlet.spi.FilterUrlMappingsProvider
56 Thu Oct 27 14:32:12 CDT 2016 META-INF/services/org.glassfish.jersey.internal.spi.ForcedAutoDiscoverable
56 Thu Oct 27 14:32:12 CDT 2016 META-INF/services/javax.ws.rs.ext.RuntimeDelegate
73 Thu Oct 27 14:32:12 CDT 2016 META-INF/services/org.glassfish.jersey.internal.spi.AutoDiscoverable
137 Thu Oct 27 14:32:12 CDT 2016 META-INF/services/org.glassfish.jersey.internal.spi.ForcedAutoDiscoverable
855 Sun Oct 02 11:14:44 CDT 2016 META-INF/services/javax.annotation.processing.Processor
Eclipse jar (works)
0 Tue Dec 13 08:55:42 CST 2016 META-INF/services/
47 Tue Dec 13 08:55:42 CST 2016 META-INF/services/javax.json.spi.JsonProvider
47 Tue Dec 13 08:55:42 CST 2016 META-INF/services/javax.ws.rs.ext.MessageBodyReader
47 Tue Dec 13 08:55:42 CST 2016 META-INF/services/javax.ws.rs.ext.MessageBodyWriter
47 Tue Dec 13 08:55:42 CST 2016 META-INF/services/javax.ws.rs.ext.Providers
50 Tue Dec 13 08:55:42 CST 2016 META-INF/services/org.glassfish.jersey.internal.spi.AutoDiscoverable
61 Tue Dec 13 08:55:42 CST 2016 META-INF/services/org.glassfish.hk2.extension.ServiceLocatorGenerator
67 Tue Dec 13 08:55:42 CST 2016 META-INF/services/javax.servlet.ServletContainerInitializer
67 Tue Dec 13 08:55:42 CST 2016 META-INF/services/org.glassfish.jersey.servlet.spi.AsyncContextDelegateProvider
63 Tue Dec 13 08:55:42 CST 2016 META-INF/services/org.glassfish.jersey.servlet.spi.FilterUrlMappingsProvider
56 Tue Dec 13 08:55:42 CST 2016 META-INF/services/org.glassfish.jersey.internal.spi.ForcedAutoDiscoverable
56 Tue Dec 13 08:55:42 CST 2016 META-INF/services/javax.ws.rs.ext.RuntimeDelegate
855 Tue Dec 13 08:55:44 CST 2016 META-INF/services/javax.annotation.processing.Processor
EDIT3:每个副本的内容 org.glassfish.jersey.internal.spi.AutoDiscoverable (3)
org.glassfish.jersey.internal.spi.ForcedAutoDiscoverable (2)
与Eclipse构建的“好”jar文件,没有重复项:
org.glassfish.jersey.internal.spi.AutoDiscoverable 中的com.owlike.genson.ext.jaxrs.JerseyAutoDiscoverable
我想我会翻阅其他META-INF的东西,所以看看可以看到什么。
org.glassfish.jersey.internal.spi.ForcedAutoDiscoverable 中的org.glassfish.jersey.jaxb.internal.JaxbAutoDiscoverable