Ricardo Memoria
Ricardo Memoria

Reputation: 483

Spring Boot Maven Plugin - Define working directory

I'm working on a spring boot app version 1.3.5.RELEASE and I'm trying to implement integration test using the spring-boot-maven-plugin (using start/stop goals). My application.properties file is currently in the target/test folder, but when running it, the app is looking for the application.properties file in the root path of the project.

Does anyone know how to set the working directory in the spring boot maven plugin?

My current plugin configuration is:

        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <version>1.3.5.RELEASE</version>
            <executions>
                <execution>
                    <id>pre-integration-test</id>
                    <goals>
                        <goal>start</goal>
                    </goals>
                    <configuration>
                        <mainClass>o.m.e.Application</mainClass>
                    </configuration>
                </execution>
                <execution>
                    <id>post-integration-test</id>
                    <goals>
                        <goal>stop</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

Upvotes: 1

Views: 1414

Answers (1)

Chathuranga Tennakoon
Chathuranga Tennakoon

Reputation: 2189

you can configure the test-property source path as follows.

@TestPropertySource(locations = "classpath:application-test.properties")

add this annotation to the Unit test class being developed.

e.g:-

@SpringApplicationConfiguration(classes = XXXXXXX.class)
@TestPropertySource(locations = "classpath: XXXXXXX.properties")
public class AppCoreGenericTests{

   //unit tests should go here 
}

Upvotes: 0

Related Questions