My desired workflow within intellij is to right click a junit @Test annotated method, and choose "run method()".
This is not working right now due to this error: Could not resolve placeholder 'spring.datasource.url' in string value "${spring.datasource.url}"
This is happening bc that value, spring.datasource.url is not defined in my application.properties file, but rather in separate profiles.
My integration test looks like this:
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = Api.class)
@IntegrationTest
@WebAppConfiguration
@ActiveProfiles(profiles = "h2")
public class ServiceIntegrationTest {
The application-h2.properties has spring.datasource.url defined.
When I run mvn test from the command line, I do not get the error above.
QUESTIONS:
spring.profiles.active somehow?@ActiveProfiles annotation?Note: these are integration tests, but I'm getting the same behavior when running unit tests from intellij.
Edit:
C:\intellij-terminal>mvn -version
Apache Maven 3.3.1 (cab6659f9874fa96462afef40fcf6bc033d58c1c; 2015-03-13T15:10:27-05:00)
Maven home: C:\bin\apache-maven-3.3.1\bin\..
Java version: 1.8.0_60, vendor: Oracle Corporation
Java home: C:\bin\java\jdk1.8.0_60\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "dos"
Edit: Also tried adding spring.profiles.active=h2 to intellij test run configuration.
Edit: I noticed intellij starts my tests with this command:
C:\bin\java\jdk1.8.0_60\bin\java
-Dmaven.multiModuleProjectDirectory=C:\dev
-Dmaven.home=C:\bin\apache-maven-3.3.1
-Dclassworlds.conf=C:\bin\apache-maven-3.3.1\bin\m2.conf
-Dfile.encoding=windows-1252
-classpath
C:\bin\apache-maven-3.3.1\boot\plexus-classworlds-2.5.2.jar
org.codehaus.classworlds.Launcher
-Didea.version=14.1.5
org.springframework.boot:spring-boot-maven-plugin:1.2.5.RELEASE:run
Questions:
I deleted .idea/ and my project's iml file and reimported. That fixed the issue.
I am glad that deleting the .iml file did the trick.
Another possibility...
mvn package -U followed by File-> Invalidate Caches and Restart.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With