【发布时间】:2019-03-20 18:33:36
【问题描述】:
自 Java 9 以来,我已经阅读了有关模块化的信息。我知道我必须创建一个模块信息,并了解哪些包是公开的和需要的。我可以看到我的类路径中确实有 Java 11。但是我收到了主题中提到的错误。更准确地说,在构建时,我得到了这个错误日志
INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ zuul ---
[WARNING] Can't extract module name from xpp3_min-1.1.4c.jar: Provider class org.xmlpull.mxp1.MXParser,org.xmlpull.mxp1_serializer.MXSerializer not in module
[WARNING] ********************************************************************************************************************
[WARNING] * Required filename-based automodules detected. Please don't publish this project to a public artifact repository! *
[WARNING] ********************************************************************************************************************
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 3 source files to C:\_d\WSs\soteste\zuul\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /C:/_d/WSs/soteste/zuul/src/main/java/module-info.java:[24,18] module not found: common
[INFO] 1 error
为了让普通项目中的类对其他项目可见,我缺少一些额外的设置?
PS1:我关注Import XXX cannot be resolved for Java SE standard classes 并设置为替代 JRE。 PS2.:我认为这与 Eclipse 无关。顺便说一句,我正在使用这个版本:
面向企业 Java 开发人员的 Eclipse IDE。 版本:2018-12 (4.10.0) 版本号:20181214-0600 操作系统:Windows 10、v.10.0、x86_64 / win32 Java版本:11.0.2
在我的zuul项目中:
import com.test.common.security.JwtConfig;
@EnableWebSecurity
public class SecurityTokenConfig extends WebSecurityConfigurerAdapter {
@Autowired
private JwtConfig jwtConfig;
...
模块信息.java
module zuul {
...
requires common;
}
在我的共同项目中
@Getter
@ToString
public class JwtConfig {
...
模块信息.java
module common {
exports com.test.common.security;
exports com.test.common;
...
}
【问题讨论】: