Engineering Building
The tools used in this project are:
JDK1.8MavenIdea
Open idea, create a new project, then right-click the project, create a new module, select Spring INITIALIZR
Then next, fill in group, artifact, and Next,
Select Web,next to complete the project creation.The project catalog is as follows:
-src
-main
-java
-package
-springbootapplication
-resouces
-statics
-
Spring Boot boot process
The Spring Boot series-5 minutes to build an app-explains how to quickly create a spring boot project and run it. Although the steps are simple and the developers save a lot of repetitive configuration work, the underlying implementation is not so simple.
In this article, we'll look at the entry class Tutorialapplication to see how spring boot starts.Annotations
Spring boot knows that there needs to be an entry class, which is the tutorialapplication in this example, an
providing those information.For instance, if we want to declare a spring MVC application using spring IO Platform and then we need to define lot of XML C Onfiguration like views, view resolvers etc. But if we use the Spring Boot Framework, then we dont need to define those XML Configuration. Spring Boot Autoconfigurator would take of this.If we use "Spring-boot-starter-web" JAR file with our project build file and then spring boot Autoconfigurator'll resolve Vie WS, view resolvers etc. automati
actually in the remote repository, and our project uses pom. xml configuration to specify the packages to be introduced.
Step 3: rewrite App. java.
When creating a Maven project, the package we specified is com. springboot. MyFirstSpringBoot. There will be an App. java in it. We will rewrite this file to the following style.
package com.springboot.MyFirstSpringBoot; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org
also register the service directly by implementing the ServletContextInitializer interface.
2. After @ ServletComponentScan annotation is used on SpringBootApplication, Servlet, Filter, and Listener can be automatically registered directly through @ WebServlet, @ WebFilter, and @ WebListener annotations without additional code.
Register the Servlet sample code using the code:
SpringBootSampleApplication. java
Package org. springboot. sample; import o
Https://stackoverflow.com/questions/40384056/consider-defining-a-bean-of-type-package-in-your-configuration-spring-bootYour Applicant class is not scanned it seems. By default all packages starting with the-the class where you have put'll be @SpringBootApplication scanned.Suppose your main class "Webserviceapplication" is in "" and then all components this com.service.something fall under "is com.service.something scanned, an D " com.service.applicant
springboot based on the added jar dependency guessing how you want to configure spring,You can select automatic configuration by adding @EnableAutoConfiguration or @SpringBootApplication annotations to a @Configuration class.Note: You only need to add a @EnableAutoConfiguration note. We recommend that you add it to the main @Configuration class.If you find that you have applied specific auto-configuration classes that you do not want, you can disable
@SpringBootApplicationEach Spring boot project has an entry class named *application that has a main method in the entry class . used in the Main method:Springapplication.run (Demoapplication.class, args);Start the spring boot app.Above is the source of @springbootapplicationYou can tell that @springbootapplication is a combination of annotations that mainly combine the following annotations
@SpringBootConfiguration: This is a configuration n
As a developer, we create projects through development tools. Often we use (e.g. Eclipse, IntelliJ idea) to quickly build project structures) but sprig-boot projects we don't need to rely on development tools toWe can create projects with a convenient approach provided by spring:Here is the address that the Sprig-boot project quickly created:Address: http://start.spring.io/After entering this address, we can see the relevant buttons; The graphical interface will know what it means to be a little
clean package to create executable jar fileRead more Spring boot executable jar example
How does the run and stop spring boot executable jar?
Open cmd or shell window and use Java-jar as shown below$ Java-jar Myproject-0.0.1-snapshot.jarTo stop use CTRL + CRead more run Spring boot jar from command line
How does the change JDK version in spring boot?
Java 1.6 As the default compiler level.You can overwrite it by adding Java.version property tag as shown below
>Dependencies>Dependencymanagement>Dependencies>Dependency>Groupid>org.springframework.cloudgroupid> artifactid>spring-cloud-dependenciesartifactid> version> Camden.sr6version> type>pomtype> scope>importscope> dependency> dependencies> DEPENDENCYMANAGEMENT> In its program entry class, add annotation @enablezipkinserver, turn on zipkinserver function:@SpringBootApplication@EnableZipkinServerpublic class ServerZipkinApplication { public stati
Main program class, main entry class/** * @SpringBootApplication to label a main program class, stating that this is a spring boot application */@SpringBootApplicationpublic class helloworldmainapplication {public static void Main (string[] args) { Springapplication.run ( Helloworldmainapplication.class,args);} }@SpringBootApplication: Spring boot app Callout in a Kevresan description This clas
One, the previous articleLast said, you can put the startup class in a non-parent directory "@Componentscan This annotation to specify the scanned package name (value=" COM.ZBB ")", where the value is an array, we can write multiple directories to scan. There is also, if useful (basepackage= "COM.ZBB") can also, can be value or can be basepackage, just an aliasSecond, automatic configurationSpringboot automatic configuration (auto-configuration) tries to automatically configure your spring app b
DATA-JPA support, we just import SPRING-BOOT-STARTER-DATA-JPA this launcher, Spring boot will import the corresponding jar package, and automatically configure the corresponding scene.The Pom file also has information about the Spring Boot Maven plugin, which can be used as a separate jar package and run with the Java-jar command as a standalone application. Build> Plugins> plugin> groupId>Org.springframework.bootgroupId> Artifactid>Spring-boot-ma
This article describes the use of Springboot timed tasks, springboot by default has been implemented for us, only need to add the corresponding annotations can be implemented.1.pom configuration filePom Bag only need to introduce springboot starter bag.true2. Startup class Enable timingThe timer can be turned on by adding @enablescheduling to the Startup class.@SpringBootApplication@EnableScheduling Public class
properties file via the Set key. Like what@Value ("${test.name}") automatically introduces the value of the Test.name configured within the properties file.The role of @ConfigurationProperties is similar to that of @value, but it is a little cumbersome to use and will not be explained.To view automatically loaded classes:If you need to the find out what auto-configuration are currently being applied, and why, start your application with The–debu G Switch. This would enable debug logs for a sele
before xxx
Spring Boot Annotations:
@SpringBootApplication: Is the core annotation of the spring Boot project The main purpose is to turn on automatic configuration
@SpringBootApplication annotation is a combination of annotations, the main combination of @configuration [email protected][email protected]
@Value: Attribute injection, read properties in properties or Yml file
@C
); listeners.finished (context, NULL); return context; } catch (Throwable ex) {handlerunfailure (context, listeners, analyzers, ex); throw new IllegalStateException (ex); } } It starts with a springapplicationrunlisteners listener, and then creates an application context Configurableapplicationcontext that loads the classes and various environment configurations required by the application.An application can function properly, need some environment variable
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.