# How to configure active profile in spring boot

**URL:** <https://discuss.gradle.org/t/how-to-configure-active-profile-in-spring-boot/32405>\
**Category:** Help/Discuss\
**Created:** [July 11, 2019, 10:50pm UTC](https://discuss.gradle.org/t/how-to-configure-active-profile-in-spring-boot/32405 "2019-07-11T22:50:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Supraja](https://avatars.discourse-cdn.com/v4/letter/s/e480ec/32.png) [@Supraja](https://discuss.gradle.org/u/Supraja)\
**Post date:** [July 11, 2019, 10:50pm UTC](https://discuss.gradle.org/t/how-to-configure-active-profile-in-spring-boot/32405/1 "2019-07-11T22:50:47Z")

</div>

I wrote a end to end test case and want to execute it as a active profile. Could someone suggest the steps. As of now I am getting error as

2: Task failed with an exception.

* * *

- What went wrong:

Cannot invoke method replaceAll() on null object

---

<div class="post-metadata">

**Author:** ![jjustinic](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/jjustinic/32/9005_2.png) [@jjustinic](https://discuss.gradle.org/u/jjustinic)\
**Post date:** [July 14, 2019, 6:17am UTC](https://discuss.gradle.org/t/how-to-configure-active-profile-in-spring-boot/32405/2 "2019-07-14T06:17:03Z")

</div>

In a Gradle `Test` task running against a Spring Boot app, it is common to specify a Spring profile as a System property in the task declaration:

```gradle
systemProperty 'spring.profiles.active', 'e2e'

```

There is not enough information here to determine why you may have a null pointer issue in your build script though.

---

<div class="post-metadata">

**Author:** ![Supraja](https://avatars.discourse-cdn.com/v4/letter/s/e480ec/32.png) [@Supraja](https://discuss.gradle.org/u/Supraja)\
**Post date:** [July 15, 2019, 9:04pm UTC](https://discuss.gradle.org/t/how-to-configure-active-profile-in-spring-boot/32405/3 "2019-07-15T21:04:03Z")

</div>

Thank you. here is my end-to-end-tests.gradle

sourceSets {  
endToEndTest {  
java {  
compileClasspath += main.output + test.output  
runtimeClasspath += main.output + test.output  
//srcDir file(‘src/endToEndTest/java’)  
srcDir file(‘/abcd-tes-layer/src/endToEndTest/java’)  
}  
resources.srcDir file(‘src/endToEndTest/resources’)  
}  
}

configurations {  
endToEndTestCompile.extendsFrom testCompile  
endToEndTestRuntime.extendsFrom testRuntime  
}

task endToEndTest(type: Test) {  
testClassesDir = sourceSets.endToEndTest.output.classesDirs  
classpath = sourceSets.endToEndTest.runtimeClasspath

```
reports.html.destination = file("${reporting.baseDir}/${name}")

```

}

and error that I get now is

- What went wrong:

A problem occurred evaluating script.

> Could not set unknown property ‘testClassesDir’ for task ‘:endToEndTest’ of type org.gradle.api.tasks.testing.Test.

Please suggest.

---

<div class="post-metadata">

**Author:** ![jjustinic](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/jjustinic/32/9005_2.png) [@jjustinic](https://discuss.gradle.org/u/jjustinic)\
**Post date:** [July 16, 2019, 2:08am UTC](https://discuss.gradle.org/t/how-to-configure-active-profile-in-spring-boot/32405/4 "2019-07-16T02:08:24Z")

</div>

The `Test` task property `testClassesDir` was deprecated and then removed in more recent versions of Gradle. You should change `testClassesDir` to `testClassesDirs`.

```groovy
task endToEndTest(type: Test) {
    testClassesDir = sourceSets.endToEndTest.output.classesDirs // this line needs to change
    classpath = sourceSets.endToEndTest.runtimeClasspath
    reports.html.destination = file("${reporting.baseDir}/${name}")
}

```
