Kann jemand erklären, warum dies der Fall ist? Zu den Lösungen gehört das Löschen der Datei modul-info.java , das Entfernen der org.openjfx.javafxplugin importieren oder wie angegeben, die XML in Ressourcen/Static/test/ verschieben oder nicht verwenden die Wertannotation, aber ich habe im Allgemeinen Schwierigkeiten, Module zu verstehen, und bin daher neugierig, warum dieses Problem auftritt. p>
Code: Select all
build.gradle
src
├───main
│ ├───java
│ │ │ module-info.java
│ │ │
│ │ └───com
│ │ └───example
│ │ App.java
│ │ TestLoader.java
│ │
│ └───resources
│ │ application.properties
│ │
│ ├───static
│ │ └───test
│ │ test.xml
│ │
│ └───test
│ test.xml
│
└───test
├───java
│ └───com
│ └───example
│ TestTest.java
│
└───resources
unused
< /code>
unused
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class App
{
public static void main(String[] args) {
SpringApplication.run(App.class, args);
}
}
< /code>
Loader:
package com.example;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource;
import org.springframework.stereotype.Component;
import java.io.IOException;
@Component
public class TestLoader
{
private TestLoader(@Value("classpath:test/test.xml") Resource fxml) throws IOException
{
fxml.getInputStream();
}
}
< /code>
Module info:
module com.example {
requires spring.boot;
requires spring.boot.autoconfigure;
requires spring.context;
requires spring.core;
requires spring.beans;
opens com.example to spring.beans, spring.context, spring.core;
}
< /code>
Gradle build file:
plugins {
id 'java'
id 'application'
id 'org.openjfx.javafxplugin' version '0.0.13'
id 'org.springframework.boot' version '3.4.2'
id 'io.spring.dependency-management' version '1.1.7'
}
group 'com.example'
version '0.0.1-SNAPSHOT'
repositories {
mavenCentral()
}
java {
modularity.inferModulePath = true
}
application {
mainModule = 'com.example'
mainClass = 'com.example.App'
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter'
testImplementation('org.springframework.boot:spring-boot-starter-test'){
// https://github.com/spring-cloud/spring- ... issues/142
exclude group: "com.vaadin.external.google", module:"android-json"
}
testImplementation("org.junit.jupiter:junit-jupiter-api")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}
tasks.named('test') {
useJUnitPlatform()
}
< /code>
Test:
package com.example;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
public class TestTest {
@Autowired
TestLoader loader;
@Test
public void test() {
}
}
< /code>
I have reviewed similar questions, but they all concern different questions. Thanks in advance!