wbk*_*wbk 27 java jaxb maven maven-compiler-plugin java-9
我正在使用maven和java-9构建我的项目.我在我的pom.xml文件中添加了:
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<compilerArgs>
<arg>--add-modules</arg>
<arg>java.xml.bind</arg>
</compilerArgs>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
但是,为了运行应用程序,我必须像这样运行它:
java -jar --add-modules java.xml.bind my-app.jar
Run Code Online (Sandbox Code Playgroud)
有没有办法构建应用程序,从命令行运行而不是--add-modules java.xml.bindjava命令行参数?
Nam*_*man 34
我刚刚回答了这个问题,作为java.se使用Maven在Java-9中公开非包的附加信息.
添加的部分特别关注使用独立版本的
java.xml.*API.为了适应这种情况,您可以开始使用jaxb-api:2.3.0可以作为模块加载的依赖关系,并且也可以从类路径执行.您需要进行的更改是将以下内容添加到依赖项列表中:
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
这样,您可以确保迁移到模块的独立API,并远离已弃用的代码段.
| 归档时间: |
|
| 查看次数: |
32596 次 |
| 最近记录: |