我正在向 Spring Boot 添加模块定义,以便能够 jlink 我的项目。我遇到的错误之一是:
Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: org.springframework.beans.factory.aspectj.AnnotationBeanConfigurerAspect not found.
Could not configure Spring Data JPA auditing-feature because spring-aspects.jar is not on the classpath!
If you want to use auditing please add spring-aspects.jar to the classpath.
at spring.data.jpa@2.0.8.RELEASE/org.springframework.data.jpa.repository.config.JpaAuditingRegistrar.registerBeanConfigurerAspectIfNecessary(JpaAuditingRegistrar.java:124)
Run Code Online (Sandbox Code Playgroud)
引发此异常的代码如下所示:
if (!ClassUtils.isPresent(BEAN_CONFIGURER_ASPECT_CLASS_NAME, getClass().getClassLoader())) {
throw new BeanDefinitionStoreException(BEAN_CONFIGURER_ASPECT_CLASS_NAME + " not found. \n"
+ "Could not configure Spring Data JPA auditing-feature because"
+ " spring-aspects.jar is not on the classpath!\n"
+ "If you want to use auditing please …Run Code Online (Sandbox Code Playgroud) Java 模块规范中使用的所有这些术语有什么区别?我找不到这些术语的定义,它不循环引用自身。
规范做出了这样的陈述,但我还没有弄清楚这些词的实际含义:
具体来说,主机系统必须将原本可观察的普通编译单元限制为仅对 M 可见的编译单元。
(JLS 11第 7.3 节,第 183 页)
我正在尝试为单个文档中的多个模块创建 javadoc (jdk11)。
我尝试这样做。
文件/目录结构为:
workspace
doc
maths
src
main
java
net.virtualpsyclab.maths
net
virtualpsyclab
maths
lib
*.java
module-info.java
genutils
src
main
java
net.virtualpsyclab.genutilsm
net
virtualpsyclab
genutilsm
*.java
module-info.java
module-info.java
jdocOptions.txt
files.lst
Run Code Online (Sandbox Code Playgroud)
jdocOptions.txt 包含:
-d doc
--module-source-path .;genutils\src\main\java\net.virtualpsyclab.genutilsm;maths\src\main\java\net.virtualpsyclab.maths
--module workspace,net.virtualpsyclab.genutilsm,net.virtualpsyclab.maths
-verbose
-overview overview.html
Run Code Online (Sandbox Code Playgroud)
files.lst 列出所有 *.java 文件。
三个 module-info.java 文件包含:
workspace\module-info.java
module workspace{
requires net.virtualpsyclab.genutilsm;
requires net.virtualpsyclab.maths;
}
workspace\genutils\src\main\java\net.virtualpsyclab.genutilsm\module-info.java
module net.virtualpsyclab.genutilsm{
exports net.virtualpsyclab.genutilsm;
}
workspace\maths\src\main\java\net.virtualpsyclab.maths\module-info.java
module net.virtualpsyclab.maths{
exports net.virtualpsyclab.maths.lib;
}
Run Code Online (Sandbox Code Playgroud)
我希望模块 net.virtualpsyclab.genutilsm 和 net.virtualpsyclab.maths 的文档出现在目录workspace\doc 中,然后运行命令:
javadoc @jdocOptions.txt @files.lst
Run Code Online (Sandbox Code Playgroud)
从目录工作区中,我看到所有源文件显然正在处理,例如:
Loading …Run Code Online (Sandbox Code Playgroud) 我有一个使用 Java 9 的 Maven 项目,并且正在使用模块。Logback 似乎从 1.3.0-alpha1 版本开始就支持这一点,但不幸的是我没有让它工作。
我从 SLF4J 收到以下消息:
SLF4J: No SLF4J providers were found.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#noProviders for further details.
Run Code Online (Sandbox Code Playgroud)
貌似找不到Logback。并使用检查(由 Jlink 生成)工件,jimage list .../modules除了 logback.xml 配置文件之外,我找不到任何有关 logback 的信息。
也许问题出在我的 module-info.java 中:
open module my.super.app {
requires jackson.annotations;
requires jdk.jsobject;
requires com.fasterxml.jackson.databind;
requires com.fasterxml.jackson.core;
requires javafx.graphics;
requires javafx.controls;
requires org.slf4j;
exports my.super.app;
}
Run Code Online (Sandbox Code Playgroud)
如何以及在哪里声明使用 Java 9 模块依赖 Logback?
我有三个名为 core、common 和 item 的模块,每个模块都是 Maven 项目的子模块。我正在使用 ServiceLoader 来实现服务方法,并使用 Java 11 和 fontawesomefx 11(最新)。
我没有使用过 Java 的模块系统,所以我不知道我对模块信息文件的处理是否正确。然而,核心和项目模块都需要 fontawesomefx 模块,并且会导致以下错误:
Error occurred during initialization of boot layer
java.lang.LayerInstantiationException: Package license in both module de.jensd.fx.fontawesomefx.materialicons and module de.jensd.fx.fontawesomefx.materialdesignicons
Run Code Online (Sandbox Code Playgroud)
所有子模块的模块信息:
module common {
requires javafx.graphics;
requires javafx.controls;
requires de.jensd.fx.fontawesomefx.commons;
exports common.abstractions;
exports common.services;
exports common.sidebar;
opens common.services;
}
module core {
requires common;
requires javafx.controls;
requires javafx.fxml;
requires de.jensd.fx.fontawesomefx.materialdesignicons;
uses common.services.ISidebarPlugin;
exports core.ui to javafx.graphics;
exports core.ui.mainpage to javafx.fxml;
exports core.ui.sidebar to javafx.fxml; …Run Code Online (Sandbox Code Playgroud) 从对我有用的badass-runtime-example-javafx开始,我复制了这个项目并用我自己的代码扩展了它。我用创建了一个图像gradlew runtime。在 Windows 上执行生成的 .bat 文件时,我收到“错误:缺少 JavaFX 运行时组件,需要运行此应用程序”。
在 build.gradle 中,我添加了一个附加模块javafx.fxml:
javafx {
modules = ['javafx.controls', 'javafx.fxml' ]
}
Run Code Online (Sandbox Code Playgroud)
我还运行了该suggestModules任务并将建议的模块添加到
runtime {
modules = ['java.naming', 'java.xml ...']
}
Run Code Online (Sandbox Code Playgroud)
我的问题是如何分析 Java 运行时缺少哪些模块。我看到它java.exe仅使用-classpath(包括应用程序 jar)和主类参数执行。
是java --list-modules答案吗?我看到 build\image\lib 中有一个大文件“模块”,它对我来说看起来很重要。
我正在寻找一种发现的分析方法来解决问题。
我正在尝试使用 JNA,因为我想使用用 C++ 编写的 .dll,而其余代码是用 Java 编写的。但是,如果我尝试导入 JNA 类,Eclipse 会声明“com.sun.jna.Library 类型不可访问”。
我的 IDE 似乎发现 JNA 以某种方式存在于我的库中,因为当我输入“import com.sun.j”时,它会向我推荐 .jna 和 .jar 文件中的其他包。
我创建了一个单独的项目来看看它是否在那里工作,但它就是不起作用。
我已经从 jna Github( https://github.com/java-native-access/jna/blob/)下载了最新的 .jar(jna-5.8.0.jar 和 jna-platform-5.8.0.jar)文件master/README.md),我已通过项目 - >配置构建路径 - >添加外部JAR将它们添加到类路径中
我正在使用 Eclipse 和 javaSE-13。
package Testtest;
import com.sun.jna.Library;
import com.sun.jna.Native;
import com.sun.jna.Platform;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
}
}
Run Code Online (Sandbox Code Playgroud)
封装结构:
Test
|-- src
| |-- TestTest
| | |-- Main.java
| |-- module-info.java
|-- …Run Code Online (Sandbox Code Playgroud) 当尝试运行其中一个模块时,我看到许多有关此错误的消息。例如:
java: module org.apache.commons.compress reads package javax.activation from both jakarta.activation and java.activation
Run Code Online (Sandbox Code Playgroud)
我应该怎么办?
我基本上正在使用一个具有复杂结构的 tomcat web 应用程序,在多个位置有许多 jar 和类,我想生成一个带有jlink其--add-modules选项的 JRE,以减少我使用的二进制文件的重量和攻击面。
澄清一下,如果我包含所有模块,jlink --add-modules ALL-MODULE-PATH一切都会顺利进行。
我已经对此进行了几次尝试:
\njdeps在整个目录上运行我需要分析的目标是一个经典的 tomcat 结构,其中包含多个位置的 jar 和类。
\n> tree -L 1 /usr/local/tomcat/ \n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 LICENSE\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 NOTICE\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 RELEASE-NOTES\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 bin\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 conf\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 db.sh\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 favicon.ico\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 lib\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 logs\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 run\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 save.sh\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 start.sh\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 stop.sh\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 temp\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 webapps\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 work\n\n> find . -name "*.jar" -o -name "*.class" | wc -l \n 938\nRun Code Online (Sandbox Code Playgroud)\n我一直在尝试以多种方式使用 jdeps,但文档并不是非常有帮助。下面是唯一返回类似于我期望的内容的命令:
\n> jdeps --recursive --print-module-deps --ignore-missing-deps /usr/local/tomcat/\njava.base,java.compiler,java.desktop,java.management,java.naming,java.scripting,java.sql\nRun Code Online (Sandbox Code Playgroud)\n这种工作符合预期,但似乎只考虑了课程。如果没有--print-module-deps我会得到一大堆像这样的未知依赖项 …
在我的 Android 应用程序项目中,我对库模块使用以下Gradle (Groovy) 配置:
// build.gradle
apply plugin: "java-library"
apply plugin: "kotlin"
dependencies {
api Libs.engelsystem
implementation(Libs.retrofit) {
exclude group: "com.squareup.okio", module: "okio"
}
testImplementation Libs.junit
testImplementation Libs.kotlinCoroutinesTest
testImplementation Libs.mockitoKotlin
testImplementation Libs.okhttpMockWebServer
testImplementation Libs.retrofitConverterMoshi
testImplementation Libs.truth
}
sourceCompatibility = Config.compatibleJavaVersion
targetCompatibility = Config.compatibleJavaVersion
compileKotlin {
kotlinOptions {
jvmTarget = Config.compatibleJavaVersion // is set to JavaVersion.VERSION_11
freeCompilerArgs += [
"-opt-in=kotlin.RequiresOptIn"
]
}
}
Run Code Online (Sandbox Code Playgroud)
Android Studio Giraffe / Lint 通知我kotlinOptions已弃用。
没有可以应用的快速修复方法。如何正确替换符号?这种库模块似乎有不同的语法。com.android.library模块中和模块中都没有弃用警告com.android.application。如果这是一个重要的区别,那么两者都使用该kotlin-android …
java-module ×10
java ×8
java-11 ×2
java-9 ×2
jlink ×2
android ×1
deprecated ×1
font-awesome ×1
gradle ×1
groovy ×1
java-platform-module-system ×1
javadoc ×1
javafx ×1
javafx-11 ×1
jdeps ×1
jna ×1
kotlin ×1
logback ×1
moditect ×1
module-path ×1
openjfx ×1
slf4j ×1
spring ×1
tomcat ×1