我每次都可以使用 Eclipse 的 Runnable Jar 向导创建一个可运行的 jar。如果我选中 Eclipse 的框以“另存为 ANT 脚本”,然后将该代码合并到 build.xml 中,然后让我们的 GitLab CI 进程进行构建并创建一个可运行的 jar,它会运行,但似乎找不到即使 .class 文件在那里,该 jar 中的一个类。
我不知道从哪里开始。Eclipse 构建与独立 java/ant 构建生成的 jar 文件相似,但不完全相同。有几件事出了问题,但目前我只能说这些了。
我怎样才能开始磨练这个?我的程序是 Jersey 网络客户端。我正在使用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/services 的内容。我不知道这是什么意思,但这是两个罐子里的内容。
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)
- com.owlike.genson.ext.jaxrs.JerseyAutoDiscoverable
- org.glassfish.jersey.logging.LoggingFeatureAutoDiscoverable
- org.glassfish.jersey.server.filter.internal.ServerFiltersAutoDiscoverable
org.glassfish.jersey.internal.spi.ForcedAutoDiscoverable (2)
- org.glassfish.jersey.jaxb.internal.JaxbAutoDiscoverable
- org.glassfish.jersey.logging.LoggingFeatureAutoDiscoverable
与 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