I just touched Spring Boot, so I made a note of what I understood as a memorandum.
For the time being, read Getting started Let's see.
Spring Boot makes it easy to create stand-alone, production-grade Spring-based Applications that you can run.
__ You can run a commercial-level Spring-based app standalone! Is it like __?
There are several ways, but all of them are able to start the application with one touch without deploying after starting the web server + application server. __ Does this area feel like "standalone"?
Download the CLI and use sprint.bat in the bin folder to start the application (class file) written in Java.
spring run created class file
Just by starting with, the web server + application server will start and Hello World will appear at localhost: 8080.
Write the required definition in pom.xml, write a controller-like class, and start the app from Maven.
mvn spring-boot:run
It is built with, the web server + application server starts, and Hello World appears at localhost: 8080.
Write the necessary definition in pom.xml, write a controller-like class, create a jar with Maven, and start the application.
mvn package
java -jar (Jar file)
Then, the web server + application server starts and Hello World appears at localhost: 8080. It seems that this Executable Jar can be used as it is as a batch file for starting and stopping services. Reference Why does Fully Executable Jar in Spring Boot work
Continue reading Building a RESTful Web Service.
Understand the basic configuration through RESTful Web API implementation samples.
MappingJackson2HttpMessageConverter
class will do it for you.@RestController
@RequestMapping
@RequestMapping (method = POST)
, mapping is common to all methods.@RequestParam
@SpringBootApplication
@EnableAutoConfiguration
, @ComponentScan
and @Configuration
together.@EnableAutoConfiguration
<bean id =" xxx ">
in Spring of Futu.
Is this the joy of Spring-boot that the app works without writing a bean definition?
(Reference) Understanding how Spring Boot AutoConfigure worksImplement the above and start the server with mvn spring-boot: run
.
When you access http: // localhost: 8080 / xxxxx
(where xxxxx is the resource name),
The mapped method of the controller is called and JSON is returned.
mvn spring-boot: run
,
The response is now displayed at http: // localhost: 8080 / greeting
,
ʻExample.javathat was created in Getting Started has stopped working. (Hello World! Does not appear at
http: // localhost: 8080 /) ⇒ The class hierarchy was as follows.
project/src/main/java/Example.java
project/src/main/java/hello/Application.java I moved Example.java under the src / main / java / hello package and it worked. Is it because
@ComponentScan` does not scan the hierarchy above itself? (No confidence)Read Official guide page. I will add what I understood.
Recommended Posts