简体   繁体   English

WildFly RestEasy版本混乱

[英]WildFly RestEasy Version confusion

I want to build a REST API using RestEasy. 我想使用RestEasy构建REST API。 The generated file should be deployed in a WildFly application server. 生成的文件应部署在WildFly应用程序服务器中。

I face the issue described in the following SO-question: AsynchronousDispatcher error 我遇到以下SO问题中描述的问题: AsynchronousDispatcher错误

The marked solution tells me, to set the dependency to "provided". 标记的解决方案告诉我,将依赖项设置为“提供”。 Which as far as I understand means, that the library is not included in my war file but taken directly from the app-server... 据我了解,这意味着该库未包含在我的战争文件中,而是直接从应用服务器中获取的...

Isn't that just wrong? 这不就是错吗?

My idea would be to build a self-containing war file which contains all the needed libraries in the version I need. 我的想法是建立一个自包含的war文件,其中包含我需要的版本中所有需要的库。

When provided from the app-server I do get the currently available version from there. 从应用服务器提供后,我确实从那里获得了当前可用的版本。 I have not really a clue about the version... when someone has the idea to update the RestEasy library on the server, it might break my app. 我不太了解版本...当有人想到更新服务器上的RestEasy库时,它可能会破坏我的应用程序。

I'm not sure whether I missed something or did something completely wrong? 我不确定我错过了什么还是做错了什么吗?

One of the big advantages to Java EE is developing towards the API and not having to worry about the implementation. Java EE的一大优势是朝着API进行开发,而不必担心实现。 Java EE containers provide the API's and implementations for the API's. Java EE容器提供API以及API的实现。 If you include implementation dependencies one of two things is likely to happen. 如果包含实现依赖关系,则可能会发生以下两种情况之一。

  1. You're dependencies will be ignored making it pointless to include them in your deployment. 您的依赖项将被忽略,使其毫无意义地将其包含在部署中。

  2. You'll get conflicts between the dependencies you included vs what the server is expecting. 您将在所包含的依赖项与服务器期望的依赖项之间发生冲突。 This could be things like: 可能是这样的:

    • ClassCastException because it's finding two of the same class on the class path. ClassCastException因为它在类路径中找到两个相同的类。
    • MethodNotFoundException because there is a version mismatch MethodNotFoundException因为版本不匹配
    • Various other issues with conflcts 冲突的其他各种问题

Developing towards the API instead of the implementation also allows you to easily switch between Java EE compliant containers with no to minimal changes to your deployment. 朝着API而非实现的方向发展还使您可以轻松地在符合Java EE的容器之间切换,而无需对部署进行最小的更改。 The API's are generally backwards compatible as well making version upgrades not as big of an issue. API通常是向后兼容的,因此版本升级也不是什么大问题。

If you want to use a fat WAR (including implementations) instead of a skinny WAR (not including the implementations) then a servlet container is probably a better solution. 如果要使用胖WAR(包括实现)而不是瘦WAR(不包括实现),则servlet容器可能是更好的解决方案。 WildFly does have a servlet only download. WildFly确实只有一个servlet下载。 I'd encourage you though to trust container to do the right thing with the implementation dependencies :). 我鼓励您尽管信任容器对实现依赖做正确的事情:)。 Usually the only time there is an issue with upgrading is if you're upgrading Java EE versions. 通常,只有在升级Java EE版本时才出现升级问题。 Even then it's usually pretty safe. 即使那样,通常也很安全。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM