“在模块java.xml.ws中声明包javax.xml.soap,该模块不在模块图中" [英] "package javax.xml.soap is declared in module java.xml.ws, which is not in the module graph"

查看:578
本文介绍了“在模块java.xml.ws中声明包javax.xml.soap,该模块不在模块图中"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我在 Working Soap客户端示例中使用了SOAP示例,将该文件放入文件SOAPClientSAAJ.java,并尝试将其编译(在Debian上为Openjdk 9):

So I took the SOAP example at Working Soap client example , put it into a file SOAPClientSAAJ.java, and tried compiling it (Openjdk 9 on Debian):

t@h ~/javatest> javac SOAPClientSAAJ.java 
SOAPClientSAAJ.java:1: error: package javax.xml.soap is not visible
import javax.xml.soap.*;
                ^
  (package javax.xml.soap is declared in module java.xml.ws, which is not in the module graph)
1 error

在搜索了一些内容之后,我发现编译和运行方式为

After Googling some, I found out that compiling and running as

t@h ~/javatest> javac --add-modules java.xml.ws SOAPClientSAAJ.java
t@h ~/javatest> java --add-modules java.xml.ws SOAPClientSAAJ

有效.另请参见此视频的一般背景: https://www.youtube.com/watch ?v = y8bpKYDrF5I& t = 20m17s

works. See also this video for general background: https://www.youtube.com/watch?v=y8bpKYDrF5I&t=20m17s

现在,问题:

  1. 编译器是否应自动添加模块java.xml.ws? (因为它显然知道它是必需的).这是javax.xml.soap中的错误吗?
  2. 为什么--add-modules选项未记录在我的手册页中? (Debian中的openjdk 9)
  3. 我应该在.java文件中写些什么来自动添加java.xml.ws模块?

推荐答案

这是实际上是Java EE软件包,依此类推现在不可见.当前的解决方法是使用--add-modules,或者使用

This is a result of the new Java 9 modules. The javax.xml.soap package is actually a Java EE package, and so now isn't visible. The current workaround is to either use the --add-modules, as you've done, or to modularize your code.

模块化代码需要将其重组为模块,并包括一个module-info.java文件,该文件指定您正在使用的模块.在您的情况下,指定java.se.ee可以访问所有EE模块.

Modularizing your code requires restructuring it into modules, and including a module-info.java file that specifies the modules you're using. In your case, specifying java.se.ee would give access to all the EE modules.

这篇关于“在模块java.xml.ws中声明包javax.xml.soap,该模块不在模块图中"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆