【发布时间】:2018-08-16 11:40:52
【问题描述】:
我有一个简单的 Hello World 示例 JAX-RS 项目。真的很简单也很愚蠢。只是最小的配置,我打算在未来增强它,想象一下这样的事情:https://robferguson.org/blog/2016/12/02/getting-started-with-resteasy/。
好吧,我的问题是,当我将 Java 版本设置为“1.9”时,我总是收到“404 not found”错误。但是当我将它改回 1.8,mvn clean install and deploy 时,它工作正常。 Java 版本是唯一的 delta,它决定了它是否工作。如何使它与 java 9 一起工作? 我确实使用 maven 3.5 和 jdk 9.0.4。
工作正常:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
返回 404:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.9</source>
<target>1.9</target>
</configuration>
</plugin>
其他所有代码都保持不变。 Wildfly 控制台中没有出现错误 - 它的行为好像路径错误,但事实并非如此,因为切换回 1.8 后,它在相同的路径下工作正常。
【问题讨论】:
-
我认为由于模块限制,您的资源不再在 Java 9 中开始扫描。
-
您是否知道任何描述如何处理模块限制和 JAX-RS 的资源?
-
这本书可能会有所帮助:javamodularity.com - 作者描述了 Java 9 中组件扫描失败的一些情况,除非采取某些措施。
标签: java maven jax-rs wildfly resteasy