Introduction to Spring Boot
- providing ability to create simple web apps very quickly
- minimizing amount of XML codebloat which is usually necessary to configure every Spring application
- most of app configuration is automatical
- simplify running and deployment process by using embedded Tomcat or Jetty servers that can run our applications without special effort and deploy process
- there are lot of so called spring boot starters which are packages containing default configuration for various fields of Spring like database access by JPA, aspect oriented programming or security
First steps
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.0.1.RELEASE")
}
}
allprojects {
apply plugin: "java"
version = '1.0-SNAPSHOT'
group = "info.rnowak.springBootFun"
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
compile "org.springframework.boot:spring-boot-starter-test:1.0.1.RELEASE"
compile "com.google.guava:guava:16.0.1"
compile "com.h2database:h2:1.3.175"
testCompile "junit:junit:4.11"
testCompile "org.mockito:mockito-all:1.9.5"
testCompile "org.assertj:assertj-core:1.5.0"
}
}
Now when we have common configuration, we can declare basic modules of application:
project(":persistence") {
dependencies {
compile "org.springframework.boot:spring-boot-starter-data-jpa:1.0.1.RELEASE"
testCompile project(":webapp")
}
}
project(":webapp") {
apply plugin: "spring-boot"
dependencies {
compile project(":persistence")
compile "org.springframework.boot:spring-boot-starter-web:1.0.1.RELEASE"
}
}
Let’s start fun with Spring!
package info.rnowak.springFun;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
@ComponentScan
@EnableAutoConfiguration
public class SpringFun {
public static void main(String[] args) {
SpringApplication app = new SpringApplication(SpringFun.class);
app.setShowBanner(false);
app.run(args);
}
}
Add some AngularJS