我有以下问题.我想在测试 - 编译阶段排除一些.java文件(**/jsfunit/*.java),另一方面我希望在编译阶段包含它们(id我用tomcat启动tomcat:运行目标)
我的pom.xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
<!-- <excludes>
<exclude>**/*JSFIntegration*.java</exclude>
</excludes> -->
</configuration>
<executions>
<!-- <execution>
<id>default-compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<includes>
<include>**/jsfunit/*.java</include>
</includes>
</configuration>
</execution>-->
<execution>
<id>default-testCompile</id>
<phase>test-compile</phase>
<configuration>
<excludes>
<exclude>**/jsfunit/*.java</exclude>
</excludes>
</configuration>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
但它不起作用:default-testCompile中的exclude不会过滤这些类.如果我删除了注释,那么所有匹配的类**/jsfunit/*.java都会被编译,但只有触摸它们!
我使用带有@Configuration批注的类来配置我的spring应用程序:
@Configuration
public class SpringConfiguration {
@Value("${driver}")
String driver;
@Value("${url}")
String url;
@Value("${minIdle}")
private int minIdle;
// snipp ..
@Bean(destroyMethod = "close")
public DataSource dataSource() {
DataSource dataSource = new DataSource();
dataSource.setDriverClassName(driver);
dataSource.setUrl(url);
dataSource.setUsername(user);
dataSource.setPassword(password);
dataSource.setMinIdle(minIdle);
return dataSource;
}
和CLASSPATH中的属性文件
driver=org.postgresql.Driver url=jdbc:postgresql:servicerepodb minIdle=1
我想在我的DAO类中获取我的DataSource配置对象:
ApplicationContext ctx = new AnnotationConfigApplicationContext(SpringConfiguration.class); DataSource dataSource = ctx.getBean(DataSource.class);
但我得到错误:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'springConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private int de.hska.repo.configuration.SpringConfiguration.minIdle; nested exception is …