0
votes

I have the following code...

@Service
public class PropertiesService {
    ...
    @Value("external.config.active") private String useExternalConfig

So in intellij I set the VM Options to...

-Dexternal.config.active=true

But when I debug in the application this.useExternalConfig.equals("external.config.active") is true.

What do I have to do to set a Spring property in the run configuration for IJ

Update I see it being supplied in the java command...

/.../java -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:53192,suspend=y,server=n -Dexternal.config.active=true -javaagent:/.../Caches/IdeaIC2018.1/groovyHotSwap/gragent.jar -javaagent:/.../Caches/IdeaIC2018.1/captureAgent/debugger-agent.jar=file:/private/var/folders/3d/5f6dvvs573zg3ydvxbd0b0h40000gn/T/capture2.props -Dfile.encoding=UTF-8 -classpath

2
Try to do it in "Command Line" instead. I have the following line in that field: spring-boot:run -Dspring.profiles.active=dev and it works - dgarceran
Sorry I misunderstood, I also need to be able to debug will using command line affect debugging? - Jackie
I also don't see a command line option in my run configuration. - Jackie

2 Answers

1
votes

@Value takes a value expression ${...} or a SpEL expression #{...} as you haven't provided any of those the value as is will be used. To substitute a property you can use a value expression ${name.of.property}.

Or if you really like hardcore you can use SpEL #{@environment.getProperty('name.of.property')}. You see the value expression is easier.

0
votes

This does seem to work...

@Value("${external.config.active}")

based on...

The actual value expression: e.g. "#{systemProperties.myProp}".

This is strange so if anyone can explain it further they get the check.