04-23.eri-test 开发第一个Spring Boot应用程序

\n

Spring Boot currently support Java, Kotlin and Groovy as language preference to create an application. You can also choose Maven or Gradle as a build automation tool. You can choose your favourite IDE ranging from Netbeans, IntelliJ ,Eclipse or Spring Tool Suite.

\n\n

We will be using Java and Maven with Spring Tool Suite.

\n\n

We can create a Spring Boot application in different ways.

\n\n
  • \n
  • Creating a maven project and adding dependencies\n
  • Using Spring Tool Suite (STS )/IntelliJ built in feature\n
  • Using Spring Initializr : https://start.spring.io\n\n
\n\n

We will be using STS built in feature and will also look at Spring Initializr. In order to create first spring boot application using STS , click on File \xe2\x86\x92 New \xe2\x86\x92 Spring Starter Project.

\n\n

\n\n

It will open a popup , where default values can be modified.

\n\n

We have modified name, group ,artifact and package default values.

\n\n

Once modified as per your requirement ,click \xe2\x80\x9cNext\xe2\x80\x9d.

\n\n

Now select Web from web stack and Devtools from Core stack.

\n\n

Selecting Dev Tool is optional. It is just because of personal choice of not starting application again and again on saving the files. We will learn about DevTool later.

\n\n

Web is an obvious choice as we are going to learn a web based Spring Boot application.

\n\n

Click Finish. Now we have a sample Spring boot application ready to go.

\n\n

\n\n

After clicking on finish , we will have project structure as shown in figure below.

\n\n

Here UserServiceApplication.java inside com.codingsaint.userservice is the main class and entry point to our application.

\n\n

Every Spring Boot Application has a main class, which acts as the entry point to application.

\n\n

Let\xe2\x80\x99s run it and see if Spring Boot application is really this easy to start and run. You can run it as a Java Application by right clicking on file and selecting Run as from menu and selecting \xe2\x80\x9c Java Application\xe2\x80\x9d or \xe2\x80\x9cSpring Boot App\xe2\x80\x9d as an option.

\n\n

Once you run it , you can see output as below on console ,where it does tell that application is running on port 8080.

\n\n

\n\n

In browser open http://localhost:8080/ and verify if server is up. Following output with 404 (default 404 of Spring Boot application) tells that server is up and running and obviously we have nothing mapped to be displayed for base URL so we are seeing this 404 error page.

\n\n

In Next section , we will see how to handle incoming requests properly. We will also dive in Spring Boot Basics

\n\n\n
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值