我究竟做错了什么?我正在使用这个小的独立应用程序运行并找到我的src/main/resources/config/application.yml
.相同的配置在JUnit中不起作用,见下文:
@Configuration
@ComponentScan
@EnableConfigurationProperties
public class TestApplication {
public static void main(String[] args) {
SpringApplication.run(TestApplication.class);
}
}
@Component
@ConfigurationProperties
public class Bean{
...
}
Run Code Online (Sandbox Code Playgroud)
以下不起作用,application.yml
未加载相同的属性并且Bean
只有null
值:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = TestApplication.class)
public class SomeTestClass {
...
}
Run Code Online (Sandbox Code Playgroud) 我的目标是在Eclipse RCP环境中创建Excel 2007文档(XLSX)(Excel 2003很简单).我不想将POI jar放在/ lib文件夹中,而是想从目标定义中使用一个有效的POI OSGI包.
到目前为止,我所有的尝试都未能创建一个有效的 OSGI POI 3.8捆绑包.到目前为止我做了什么:
我将所有相关的JAR文件与Ant zip任务合并:
我使用wrap参数运行了bnd工具:java -jar biz.aQute.bnd.jar wrap ./poi-3.8-beta3-20110606-merged.jar
我必须使用bnd分别将/ ooxml-lib文件夹中的jar包捆绑在一起:
这导致ClassNotFoundExceptions org.w3c.dom.Node
因为xmlbeans-2.3.0.jar从此包导出四个类org.w3c.dom
.通常,JavaSE-RuntimeEnvironment会导出这些.
我org/w3c/dom
从xmlbeans-2.3.0.jar中删除了该文件夹并重新绑定了jar但我得到了其他ClassNotFoundExceptions.
这是我到目前为止的地方.我认为使用bnd wrap是不够的.可能我必须创建一个bnd.properties文件并具有显式的Export-Package/Import-Package语句但哪些有效?
那么,有没有人成功地创建了一个有效的POI 3.8 OSGI捆绑包?
就像标题中所说的,我在中有一个mapper接口src/test/java
,它不是由mapstruct处理器生成的。
在同一项目中,src/main/java
将生成所有映射器。这是预期的行为吗?
如何在测试源中生成映射器?
编辑(更多信息):
简化的Maven模块结构:
root_project
-> module_1
Run Code Online (Sandbox Code Playgroud)
的pom.xml root_project
<build>
<pluginManagement>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<annotationProcessorPaths>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>1.1.0.Final</version>
</path>
</annotationProcessorPaths>
<compilerArgs>
<compilerArg>
-Amapstruct.defaultComponentModel=spring
</compilerArg>
</compilerArgs>
</configuration>
</plugin>
...
Run Code Online (Sandbox Code Playgroud)
的pom.xml module_1
基本上是空的:
<dependencies>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-jdk8</artifactId>
<scope>compile</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)