Boot provides the default configuration of the template engine mainly in the following ways:
Thymeleaf
Freemarker
Velocity
Groovy
Mustache
Spring boot recommends using these template engines to avoid using JSPs, and if you must use JSP, you will not be able to implement many of the features of s
Brief introductionDid you retreat from the complex configuration when you first contacted and learned the spring framework for the 1th time? When you use the Spring framework for Nth times, do you feel bored with a bunch of sticky configurations? Try spring boot to make it easier and faster to build your
Preparatory workFirst, build a simple Web project that you can use to add security controls later, or use the Chapter3-1-2 as a foundation project. If you are building a web app using spring boot, you can first read the article "Spring Boot Development web App".Web tier Implementation Request mapping[
Source Address: Https://github.com/roncoo/spring-boot-demo1. Tools:Eclipse:http://www.eclipse.org/downloads/packages/eclipse-ide-java-ee-developers/neonrSpring Tool Suite:https://spring.io/tools/sts/all2. Use the version as:Eclipse:eclipse-jee-neon-r-win32-x86_64.zipSpring Tool Suite:springsource-tool-suite-3.8.0.release-e4.5.2-updatesite.zip3. Installation steps
, respectively, based on the execution phase in which the Spring Boot application is located. Understand the role of the spring boot Bean configuration source, the role of WEB application type inference to the Spring application context type, and the
thinking to manipulate the database at will. Hibernate can be applied to any JDBC application, both in Java client applications and in servlet/jsp Web applications, and most revolutionary of all, hibernate can replace CMP in the EE architecture of the EJB application. The task of achieving data persistence.?? This article describes how to use spring Data JPA and hibernate to connect and process the MySQL d
complex. In order of precedence from highest to lowest, the specific list is as follows.
command-line arguments.
The Java system parameters obtained through System.getproperties ().
Operating system environment variables.
The JNDI attribute obtained from java:comp/env.
The "random.*" property generated by Randomvaluepropertysource.
apply a property file other than the Jar file . (via spring.config.location parameter)
configure multiple properties on our own
We delete the. properties suffix file, use the. yml file for a simple configuration, and then use the @Value to get the configuration properties:Restart Spring Boot, enter address: Localhost:8080/hello can see the correct result:
Note: We did not specify the type of the attribute in the Yml file, but it was defined when it was used.
You can a
priority order provided by Spring Boot is more complex. In order of precedence from highest to lowest, the specific list is as follows.
command-line arguments.
The Java system parameters obtained through System.getproperties ().
Operating system environment variables.
The JNDI attribute obtained from java:comp/env.
The "random.*" propert
Spring-boot-maker directory Dockerfile
Because the Add and copy commands in Dockerfile only support relative paths, they cannot be manipulated with absolute paths.
While modifying the Pom.xml file in the Spring-boot-maker project, the jar file is packaged directly into the Dockerfile directory, which does not conform
Springboot uses Spring Boot Actuator to Monitor the application, springbootactuator
The characteristics of microservices determine that functional modules are deployed in a distributed manner. Most functional modules run on different machines and interact with each other through service calls, the frontend and backend business flows are processed and transmitted by many microservices. If an exception occurs
Spring Boot application development started, springboot Application DevelopmentCreate a Spring Boot Application
Spring Boot supports multiple integration methods, such as CLI, Maven, and Gradle. Here, Mavan is used as an example.
With the release of the new Spring 4 release, Spring Boot's new sub-project has received a wide range of attention, as both the Spring 4 official press release and the interview with the chief architect, Adrian Colyer, have praised the productivity gains of this subproject. Spring
)
Compile with mvn clean compile.3. Firstboot.javaPackage com.xxx.firstboot;Import org.springframework.boot.SpringApplication;Import org.springframework.boot.autoconfigure.EnableAutoConfiguration;Import org.springframework.web.bind.annotation.RequestMapping;Import Org.springframework.web.bind.annotation.RestController;/*** @RestController: Note from spring MVCD,* equivalent to @controller and @responsebody, can be directly returned to JSON** @Ena
Spring Boot because of its1, easy to develop and maintain. 2, a single micro-service start fast. 3, local modification deployment is easy. 4, the technology stack is not subject to language restrictions and other advantages by more and more companies pay attention to. Spring-boot also integrates many frameworks for mic
, throw MyException exception[Java] View plain copy@Controllerpublic class Hellocontroller {@RequestMapping("/json") public String json() throws MyException { throw new MyException("发生错误2"); } }Create a corresponding processing for a myexception exception[Java] View plain copy@ControllerAdvicepublic class Globalexceptionhandler {@ExceptionHandler(value = MyException.class) @ResponseBody public Err
Spring Boot CLI
Springboot provides a console command tool that can be used to quickly build a spring-based prototype. It supports running groovy scripts, which means you can use Java-like syntax, but you don't have to write a lot of template code.Download Address:https://repo.spring.io/release/org/springframework/
, for example:Spring.thymeleaf.mode:HTMLPlease refer to the Thymeleaf 3 for sample to see this in action.If you is using any of the other auto-configured Thymeleaf Extras (Spring Security, Data Attribute, or Java 8 time) your S Hould also override each of the their versions to one that's compatible with Thymeleaf 3.0.http://docs.spring.io/spring-
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.