Improperly parsing environment variables in pom.xml
we have a simple system property set in our pom.xml
<systemPropertyVariables>
<spring.profiles.active>${SPRING_PROFILES_ACTIVE}</spring.profiles.active>
</systemPropertyVariables>
when running maven on the command line, or within eclipse, since the SPRING_PROFILES_ACTIVE environment variable is not set, it gets substituted to a bland string ""
when importing the project into IntelliJ, intelliJ will set the spring.profiles.active system property to the value "${SPRING_PROFILES_ACTIVE}" and in our case, it will then cause spring to think it is an expression and yield
Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'SPRING_PROFILES_ACTIVE' in string value [${SPRING_PROFILES_ACTIVE}]
Now, the work around is simple, we can either set the environment variable or we can configure -Dspring.profiles.active= as a VM option in the run configurations. However, it feels like the correct thing would have been to mimic the Maven behavior properly.
any thoughts? is this an issue?
thanks in advance for your time
Filip
请先登录再写评论。
Hello.
Where do you have this systemPropertyVariables in your pom.xml?
What goal (or any other action) fails in IDEA?
Thank you,
Alexander.
You can see the variable definition here
https://github.com/cloudfoundry/uaa/search?l=xml&q=spring.profiles.active&ref=cmdform
and the project, all I did was import the
https://github.com/cloudfoundry/uaa/
into IntelliJ.
No goals fail, but when I run any unit test, IntelliJ sets the -Dspring.profiles.active to "${...}" instead of resolving the variable to empty ""
Thank you.
And what does fail? I've run a surefire goal from Maven tool window, it goes with no error.
Regards,
Alexander.
Any test that depends on IntelliJ to properly resolve variables will fail.
Here is a simple reproducible test
1. git clone https://github.com/fhanik/idea.git
2. cd idea/my-app
3. mvn test
Step 3 'mvn test' here succeeds.
4. Now import this project into IntelliJ,
5. Locate the class AppTest
6. Right Click on AppTest and Select Run
Step 6 - this test fails.
Import the project into eclipse, and the test succeeds.
The bug in intellij is that it doesn't properly do variable substitution.
the command line for the unit test becomes
/software/java/jdk1.7.0_51_x64/bin/java -ea -Dspring.profiles.active=${SPRING_PROFILES_ACTIVE} -Didea.launcher.port=7532 -Didea.launcher.bin.path=
as you can see, it did not properly set the system property to an empty value.
Thanks a lot. Filed an issue: http://youtrack.jetbrains.com/issue/IDEA-120890
Regards,
Alexander.