我有一个小项目,当我让它运行时确实会引发异常。
问题在这里(TestObject.java):
final JAXBContext jaxbContext = JAXBContext.newInstance(...);
Run Code Online (Sandbox Code Playgroud)
我真的不明白为什么会抛出异常。我还创建了一个像超级按钮一样工作的测试(TestTest.java)。请原谅我的名字,但这只是一个小的测试应用程序,它可以与Java 11一起使用。
我遵循以下步骤:javax.xml.bind.JAXBException在模块路径或类路径上未找到 并添加了JAXB-API的实现
compile('javax.xml.bind:jaxb-api:2.3.0')
compile('javax.activation:activation:1.1')
compile('org.glassfish.jaxb:jaxb-runtime:2.3.0')
Run Code Online (Sandbox Code Playgroud)
到我的build.gradle,但随后它抱怨
Error:java: module not found: java.activation
Run Code Online (Sandbox Code Playgroud)
不见了。由于这也从Java 11中删除,因此我添加了:
compile 'com.sun.activation:javax.activation:1.2.0'
Run Code Online (Sandbox Code Playgroud)
但随后引发了很多错误:
Error:java: the unnamed module reads package com.sun.xml.bind from both jaxb.runtime and jaxb.core
Error:java: the unnamed module reads package com.sun.xml.bind.util from both jaxb.runtime and jaxb.core
Error:java: the unnamed module reads package com.sun.xml.bind.marshaller from both jaxb.runtime and jaxb.core
Error:java: the unnamed module reads package com.sun.xml.bind.api from both jaxb.runtime and jaxb.core
Error:java: the unnamed module reads …Run Code Online (Sandbox Code Playgroud) 我有一个小的 Spring Boot 应用程序,它在 src/main/resources 中提供了一个 application.properties - 这就像一个魅力。用户现在应该能够配置更多内容(2 个凭据),因此我期望类路径中有一个名为“matrixregistration.config”的文件。不幸的是,无论在哪里都找不到这个文件。该应用程序通过 gradle spring boot 任务 bootDistZip 进行分发。
@Configuration
@PropertySource("classpath:matrixregistration.config")
@Validated
public class MatrixRegistrationConfiguration {
private String sharedSecret;
private String registrationPassword;
...
Run Code Online (Sandbox Code Playgroud)
我的分发包位于服务器上的 /home/matrix/matrixregistration-boot 上,有一个“bin”和一个“lib”文件夹。我希望当我将配置放入此目录并使用 ./bin/matrixregistration 启动应用程序时,类路径应包含“.” 并找到配置。但事实并非如此。配置文件就在那里。
例外情况:
matrix@myhost:~/matrixregistration-boot$ ./bin/matrixregistration
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | …Run Code Online (Sandbox Code Playgroud)