Created
September 21, 2017 16:42
-
-
Save hkarakose/f28aec966dda8b2a7abd3920b6c17a47 to your computer and use it in GitHub Desktop.
Following class print spring.datasource configuration properties in a spring-boot application. This class can be useful if used during application startup.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.kodfarki.scheduler; | |
import org.springframework.boot.context.properties.ConfigurationProperties; | |
import org.springframework.stereotype.Component; | |
/** | |
* User: Halil Karakose | |
* Date: 21/09/2017 | |
* Time: 19:31 | |
*/ | |
@ConfigurationProperties("spring.datasource") | |
@Component | |
public class ApplicationProperties { | |
private String url; | |
private String username; | |
public String getUrl() { | |
return url; | |
} | |
public void setUrl(String url) { | |
this.url = url; | |
} | |
@Override | |
public String toString() { | |
final StringBuilder sb = new StringBuilder("ApplicationProperties{"); | |
sb.append("url='").append(url).append('\''); | |
sb.append(", username='").append(username).append('\''); | |
sb.append('}'); | |
return sb.toString(); | |
} | |
public String getUsername() { | |
return username; | |
} | |
public void setUsername(String username) { | |
this.username = username; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment