Skip to content

Instantly share code, notes, and snippets.

@wonderb0lt
Created December 15, 2014 17:33
Show Gist options
  • Save wonderb0lt/3c28bdd6c1eabab5ed6d to your computer and use it in GitHub Desktop.
Save wonderb0lt/3c28bdd6c1eabab5ed6d to your computer and use it in GitHub Desktop.
The Java app for the cfn/docker sample
package lt.wonderb0.example;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Configuration
@ComponentScan
@Controller
@EnableAutoConfiguration
public class Application {
@Autowired
private ApplicationContext applicationContext;
@Autowired
private ApplicationSetup setup;
@RequestMapping("/hello")
@ResponseBody
public String sayHello() {
return setup.getGreeting();
}
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
package lt.wonderb0.example;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@Component
public class ApplicationSetup {
@Value("${echoservice.greeting:Hello, World!}")
private String greeting;
public String getGreeting() {
return greeting;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment