简体   繁体   English

运行Gradle测试时找不到属性文件

[英]Can't find properties file when running gradle test

I am using gradle to build and test my application. 我正在使用gradle构建和测试我的应用程序。 I use the command 我使用命令

gradle test

But the testing, which works perfectly when run from within eclipse, fails when run using gradle. 但是,当从eclipse中运行时,该测试效果很好,但使用gradle运行时却失败了。 My test is defined below and the properties file that it cannot find is in both these folders: 我的测试在下面定义,并且找不到的属性文件在这两个文件夹中:

/home/user/Development/git/myproject/src/main/java/com/mycompany/config /home/user/Development/git/myproject/src/test/resources / home / user / Development / git / myproject / src / main / java / com / mycompany / config / home / user / Development / git / myproject / src / test / resources

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(loader = AnnotationConfigContextLoader.class, classes = {      ApplicationConfig.class })
public class WebImportTest {
    @Resource
    private Environment env;

    @Autowired
    private JestClient jestClient;

my java configuration looks like so: 我的java配置如下所示:

@Configuration
@ComponentScan({ "com.mycompany" })
@PropertySource("classpath:/com/mycompany/config/myproject.properties")
@Import(PersistenceConfig.class)
public class ApplicationConfig {

    @Resource
    private Environment env;

I am not experience enough in order to figure out what is the cause of this 我没有足够的经验来弄清楚这是什么原因

:myproject is getting tests from [task ':test']
:compileJava
Note: /home/user/Development/git/myproject/src/main/java/com/mycompany/entities/generated/Keys.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
:processResources UP-TO-DATE
:classes
:instrument SKIPPED
:copyCoberturaDatafile SKIPPED
:compileTestJava
:processTestResources UP-TO-DATE
:testClasses
:test

com.mycompany.myProject.DBConnectionTest > initializationError FAILED
java.lang.Exception

com.mycompany.myProject.WebImportTest > testWebImport FAILED
    java.lang.IllegalStateException
        Caused by: org.springframework.beans.factory.BeanDefinitionStoreException
            Caused by: java.io.FileNotFoundException

Why is the properties file not found?! 为什么找不到属性文件?

属性文件需要进入src/main/resources/com/mycompany/config

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Springs框架之外运行gradle测试时找不到属性文件 - Can't find properties file when running gradle test outside of Springs framework 运行junit测试时找不到.class文件 - Can't find the .class file when running a junit test 在 IntelliJ 上运行测试时无法加载 messages.properties - Can't load messages.properties when running test on IntelliJ 运行测试类时,在 Spring Maven 项目中,使用 @Value 注释无法从 .properties 文件中正确读取属性 - When running test class, properties can't be read properly from .properties file by using @Value annotation, in Spring Maven project 部署时,Maven Vaadin War无法找到属性文件 - Maven vaadin war can't find a properties file when deployed 为什么在 java_test 规则上运行 bazel 测试时 Bazel 找不到我的测试 class? - Why can't Bazel find my test class when running bazel test on a java_test rule? 通过Eclipse运行时,Java无法找到文件 - Java can't find file when running through Eclipse Jenkins Gradle测试任务失败,找不到导入文件 - Jenkins failing gradle test task, can't find import files gradle 在集成测试中找不到 lombok 生成的构造函数 - gradle can't find lombok generated constructor in integration test 无法使用Gradle获取测试代码以查找源代码 - Can't get test code to find source code using gradle
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM