Difference between revisions of "Spring tips"

From DarkWiki
Jump to: navigation, search
(Created page with "==@Value== <source lang="java"> @Value("${prop.name:#{systemProperties['java.io.tmpdir']+'/pa-git'}}") private String localDir; </source> <source lang="java"> @V...")
 
(@Value)
Line 1: Line 1:
 
==@Value==
 
==@Value==
 +
 +
Apply a setting, defaulting to a subdirectory of the temporary folder.
  
 
<source lang="java">
 
<source lang="java">
     @Value("${prop.name:#{systemProperties['java.io.tmpdir']+'/pa-git'}}")
+
     @Value("${prop.name:#{systemProperties['java.io.tmpdir']+'/subdir'}}")
 
     private String localDir;
 
     private String localDir;
 
</source>
 
</source>
 +
 +
When a value is not present in the application.properties file, assume null.
  
 
<source lang="java">
 
<source lang="java">

Revision as of 07:22, 5 July 2017

@Value

Apply a setting, defaulting to a subdirectory of the temporary folder.

    @Value("${prop.name:#{systemProperties['java.io.tmpdir']+'/subdir'}}")
    private String localDir;

When a value is not present in the application.properties file, assume null.

    @Value("${prop.name:#{null}}")
    private String remoteUrl;