Deep learning of micro-frame Spring Boot

Source: Internet
Author: User
Deep learning micro-frame: Spring Boot
Author Dan Woods, translator Zhang Weibi posted on May 13, 2014


Spring boot, a new framework provided by the pivotal team, is designed to simplify the initial set-up and development process of new spring applications.
The framework is configured in a specific way so that developers no longer need to define a boilerplate configuration.
In this way, boot is committed to becoming a leader in the booming field of rapid application development (rapid application development).


For years, the Spring IO platform has been criticized for a large number of XML configurations and complex dependency management.
At last year's Springone 2GX meeting, Pivotal's CTO Adrian Colyer responded to these criticisms,
And, specifically, one of the future goals of the platform is to implement a development experience that is free of XML configuration.


The functionality implemented by the boot is beyond the description of this task, and developers are not only no longer required to write XML, but in some scenarios they do not even need to write tedious import statements.
At the time of the release of the externally released beta release, boot describes how to use the framework to implement a Web application that can be run within 140 characters,
Thus gaining a great deal of attention, the sample is posted on a tweet.


However, spring boot is not intended to be a replacement for many of the "Foundation" layer projects in the Spring IO platform.
The goal of Spring boot is not to provide new solutions for resolved problem domains, but to bring another development experience to the platform, simplifying the use of these technologies.
For developers already familiar with the spring ecosystem, boot is an ideal choice,
But for new spring-tech newcomers, boot provides a much simpler way to use these technologies.


In the quest for a boost to the development experience, spring Boot can even say that the entire Spring ecosystem uses the Groovy programming language.
The many handy features provided by the boot are achieved with the help of groovy's powerful MetaObject protocol, the pluggable AST conversion process, and the built-in dependency solution engine.
In its core compilation model, boot uses groovy to build engineering files,
So it can use the common import and boilerplate methods (such as the main method of the class) to decorate the byte code generated by the class (decorate).
This application, which is written using the boot, can be very concise, but it can still provide many functions.


First, install the boot
At its most fundamental, Spring boot is a collection of libraries that can be used by the build system of any project.
For simplicity, the framework also provides a command-line interface that can be used to run and test the boot application.
The release version of the framework, including the integrated CLI (command-line interface), can be manually downloaded and installed in the Spring warehouse.
A simpler way to do this is to use the Groovy Environment Manager (Groovy Environment MANAGER,GVM), which handles the installation and management of the boot version.
The boot and its CLI can be installed through the GVM command line GVM install Springboot.
Install boot on OS X to use the Homebrew Package Manager.
To complete the installation, you first switch to the pivotal warehouse using brew tap Pivotal/tap, and then execute the Brew install Springboot command.


The projects to be packaged and distributed depend on a build system such as Maven or Gradle.
To simplify the dependency graph, the boot function is modular, and many dependencies can be added to the project by importing the boot so-called "starter" module.
To make it easier to manage dependent versions and use the default configuration, the framework provides a parent POM, which the project can inherit.
The sample Pom file definition for the Spring boot project is shown in Listing 1 of the program.


Program Listing 1
<?xml version= "1.0" encoding= "UTF-8"?>
<project xmlns= "http://maven.apache.org/POM/4.0.0" xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"
xsi:schemalocation= "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" >
<modelVersion>4.0.0</modelVersion>


<groupId>com.example</groupId>
<artifactId>myproject</artifactId>
<version>1.0.0-SNAPSHOT</version>


<!--Inherit defaults from Spring Boot-->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.0.0.RC1</version>
</parent>


<!--Add Typical dependencies for a Web application-->
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
</dependencies>


<repositories>
<repository>
<id>spring-snapshots</id>
<url>http://repo.spring.io/libs-snapshot</url>
</repository>
</repositories>


<pluginRepositories>
<pluginRepository>
<id>spring-snapshots</id>
<url>http://repo.spring.io/libs-snapshot</url>
</pluginRepository>
</pluginRepositories>


<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>


To achieve a simpler build configuration, developers can use Gradle to build a concise groovy DSL in the system, as shown in listing 1.1 of the program.
Program Listing 1.1


Buildscript {
repositories {
Maven {URL "http://repo.spring.io/libs-snapshot"}
Mavencentral ()
}
dependencies {
Classpath ("Org.springframework.boot:spring-boot-gradle-plugin:1.0.0.rc1")
}
}


Apply plugin: ' java '
Apply plugin: ' Spring-boot '


repositories {
Mavencentral ()
Maven {URL "http://repo.spring.io/libs-snapshot"}
}


dependencies {
Compile ' org.springframework.boot:spring-boot-starter-actuator:1.0.0.rc1 '
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.