Guest User

Untitled

a guest
Apr 26th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. <parent>
  2. <groupId>org.springframework.boot</groupId>
  3. <artifactId>spring-boot-starter-parent</artifactId>
  4. <version>2.0.0.RELEASE</version>
  5. </parent>
  6.  
  7. @Configuration
  8. @PropertySource("file:/etc/koshka/application.properties")
  9. public class Config
  10. {
  11. @Autowired
  12. private Environment env;
  13.  
  14. @Bean
  15. public static PropertySourcesPlaceholderConfigurer configurer() {
  16. return new PropertySourcesPlaceholderConfigurer();
  17. }
  18.  
  19. @Value("${socmess.pass}")
  20. private String pass;
  21.  
  22. public String getUser() {
  23. return env.getProperty("socmess.user");
  24. }
  25.  
  26. public String getPass() {
  27. return pass;
  28. }
  29. }
  30.  
  31. $ cat /etc/koshka/application.properties
  32. socmess.user="testuser"
  33. socmess.pass="testpass"
  34.  
  35. @RestController
  36. public class Sender {
  37. private final Logger logger;
  38.  
  39. public Sender()
  40. {
  41. logger = (Logger)LogManager.getLogger("KoshkaBot");
  42. }
  43.  
  44. @GetMapping("/vk")
  45. @CrossOrigin(origins = "*")
  46. public ResponseEntity<String> vk(
  47. @RequestParam(value="username") String username,
  48. @RequestParam(value="password") String password
  49. ) {
  50. Config conf = new Config();
  51.  
  52. logger.info(conf.getUser());
  53. logger.info(conf.getPass());
  54.  
  55. return ResponseEntity.ok().body("OK");
  56. }
  57. }
Add Comment
Please, Sign In to add comment