Deploy SpringBoot server in IDEA

Table of contents

I. Introduction

2. Modify pom.xml

Edit

3. Write the startup main program

Edit

4. Create Controller

Edit

4. Operation

Summarize


I. Introduction

Prerequisites: IDEA, JDK

Create a Maven project

2. Modify pom.xml

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.5.0</version>
    </parent>





        <!-- web starter, 自动配置SpringMVC,内置tomcat -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

 

3. Write the startup main program

package com.iflytek;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
@MapperScan("com.iflytek.dao")
public class Application {
public static void main(String[] args) {

    SpringApplication.run(Application.class, args);
    }
}

4. Create Controller

package com.sodaopen.controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HelloController {
@GetMapping("/hello")
public String sayHello(){
return "Hello, Spring Boot";
}
}

4. Operation

1. Run the main program (rendering):

2. Enter the TomCat URL in the browser:

http://localhost:8080/hello

Final running effect:

 

 

Summarize

         After deploying the SpringBoot project, you can continue to build more Spring programs.

When the SpringBoot project is deployed together with other projects, the SpringBoot main program may fail to start. The common reason is that other dependencies in the pom file may conflict with SpringBoot dependencies. The solution: Redeploy Spring in a new project. project, or comment out other irrelevant dependencies first.

Guess you like

Origin blog.csdn.net/weixin_61569821/article/details/128330724