Static resource accessWhen we develop Web applications, we need to reference a large number of JS, CSS, pictures and other static resources.Default configurationSpring boot defaults to provide a static resource directory location to be placed under Classpath, and the directory name must conform to the following rules:
/static
/public
/resources
/meta-inf/resources
Example: We can c
-tomcat-tmp # Open the Tomcat Access log and set the log format: # server. tomcat. access-log-enabled = true # server. tomcat. access-log-pattern = # accesslog Directory, which is in basedir/logs # server by default. tomcat. accesslog. directory = # log file directory logging. path = H:/springboot-tomcat-tmp # Name of the log file. The default value is spring. loglogging. file = myapp. log
JettyIf you want
is Spring Data JPA capable of?can greatly simplify the The JPA notation enables access to and manipulation of data in situations where there is little or no write implementation. except CRUD , it also includes some common functions such as paging, sorting, and so on. first of all, we need to be clear Spring Data is an open source framework in which spring data J
@EnableAutoConfiguration annotation?
This annotation tells Spring Boot to "guess" what you'll want to configure Spring, based on the jar dependencies that's you Have added.Read more @enableautoconfiguration Spring Boot example
exception information logging and query.Connection pooling monitoring: monitor the status of the current system database connection pool to analyze SQL to identify system performance bottlenecks.Source source technical support for complete projects 17917433806. Source code Structure6. Registration CenterYou are welcome to study the relevant technology to understand the framework of technology or source of friends directly to seekSource source technic
see, our service has been successfully started.4.5 Process AnalysisYou might wonder why we didn't configure the database information, but we didn't report the exception. We clearly created the Readrepository database interface, if there is no datasource, it should be reported abnormal. But spring boot cleverly avoids the problem.First we need to know about spring
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
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 the properties file outside of the Jar file . (via spring.config.location parameter)
Apply the properties file inside the Jar
Spring Boot creates beans using Java code and registers them to Spring.
From Spring3.0, a new method is added to configure Bean Definition, which is to configure Bean Definition through Java Code.The two configuration methods differ from Xml and Annotation:
The first two Xml and Annotation configuration methods are pre-defined, that is, after developers use the X
Background: Since the version beginning with spring boot 1.4 is going to be log4j2, the format supported is JSON and XML two formats, this practice mainly uses the XML format definition log description.The development steps for spring boot 1.5.8.RELEASE to introduce log4j2 are as follows:1. First remove the
can see that the Springbootdemo.log file was generated under the specified path, and the contents of the file are consistent with the console print.
If logging.file=springbootdemo.log the comment generates a default file name Spring.log
How to set the log level
There is a total of Tarce
In the example above we have printed an info-level log because the spring boot
ContextPath, generally in the official release version, we do not configure
Server.context-path=/myspringboot
# error page, specifying the URL of the jump when an error occurs. Please check the Basicerrorcontroller source code to know
Server.error.path=/error
# Service Port
server.port=9090
# Session maximum timeout (minutes), default is
server.session-timeout=
# The service binds the IP address, and when the server is started, if the IP address is not the same
Java Spring boot uses spring reflection and bootspring
Spring reflection
1. You can instantiate this class by class name.
ApplicationContext. getBean (name)2. Get classes by type
applicationContext.getBeansOfType(clazz);
First, you must obtain the spring container. The Appli
packages are provided by the specific Spring Boot: \repository\org\springframework\boot\spring-boot-dependencies\ 2.0.1.release\spring-boot-dependencies-2.0.1.release.pom file to view,
You need to restart the server to modify information in the web environment. If you often restart the server in a large project, you can imagine the waste of time. Today we will introduce spring boot! Generally, learning begins with hello world! The following describes how to configure and use spring boot in maven!
Con
development process based on this project. For feature development with spring boot, you need to use Gradle or Maven as the build tool. In this example, we'll use Eclipse and Maven plug-ins for development. To use Spring Boot, first create a MAVEN project and modify the MAV
fast Java and Web applications with a simple configuration.By following the steps below, you can start writing your first application.Source Code:https://github.com/herotl2005/spring-data-elasticsearch-sampleRequirement enviroment1. Install Elasticsearch2. Install Gradle3. IDE Eclipse or Intellij ideaStep by Step Coding1. Gradle Builddependencies {testcompile group: ' JUnit ', Name: ' JUnit ', Version: ' 4.11 ' compile ' org.springframework.boot:
Spring Boot
Spring Boot is a new framework provided by the pivotal team designed to simplify the initial setup and development of new spring applications. The framework uses a specific approach to configuration, which eliminates the need for developers to define boilerplate
-initialize a new project using Spring Initializr (start.spring.io) usage:spring init [options] [location] O Ption Description------------------A,--artifactid Project coordinates; Infer Archive name (for example ' test ')-B,--boot-version Spring boot version (for
properties in Application.properties,In addition, if you have both Application.properties and application.yml at the same priority location, the attributes inside the APPLICATION.YML will overwrite the attributes in the application.properties.profile-Multi-environment configurationWhen an application needs to be deployed to a different operating environment, some configuration details are usually different, the simplest of which is logging, which set
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.