On Github Juwit / reveal-spring-boot
Software Architect at Sopra Steria (XNet)
XML based configuration
<bean id="exampleBean" class="examples.ExampleBean"> <!-- setter injection using the neater ref attribute --> <property name="beanTwo" ref="yetAnotherBean"/> <property name="integerProperty" value="1"/> </bean> <bean id="anotherExampleBean" class="examples.AnotherBean"/> <bean id="yetAnotherBean" class="examples.YetAnotherBean"/>
Java annotations
@Component public class SimpleMovieLister { private MovieFinder movieFinder; @Autowired public void setMovieFinder(MovieFinder movieFinder) { this.movieFinder = movieFinder; } }
Maven plugin (using spring-boot-starter-parent):
<plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin>
$ mvn package
Gradle plugin:
apply plugin: 'spring-boot'
$ gradle repackage
$ java -jar yourapp.jar
SpringApplication adds command line arguments to the Spring Environment so you can refer inject them into beans:
@Value("${name}") private String name;
$ java -jar target/yourapp.jar --name=Dave
You can also configure Spring Boot itself:
$ java -jar target/*.jar --server.port=9000
Just put application.properties in your classpath or next to you jar, e.g.
server.port: 9000
Just include snake-yaml.jar and put application.yml in your classpath
server: port: 9000
Activate external configuration with a Spring profile file name convention e.g. application-development.properties
Set the default spring profile in external configuration, e.g:
spring.profiles.active: default, postgresql
Adds common non-functional features to your application and exposes MVC endpoints to interact with them.
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency>
{ "mem": 582443, "mem.free": 426152, "processors": 4, "instance.uptime": 43066, "uptime": 52326, ... }
FROM java:8 ADD youapp.jar app.jar EXPOSE 8080 ENTRYPOINT ["java","-jar","app.jar"]
build your image and run anywhere!