Home > Java > javaTutorial > body text

Springboot project deployment method

PHPz
Release: 2023-05-18 15:10:06
forward
1436 people have browsed it

1 Introduction

Springboot is equivalent to a practical tool framework. It integrates the three major frameworks of ssm and simplifies the development steps, eliminating the cumbersome environment setup and various spring configurations in ssm. In short , which is a very practical framework.

2 Getting Started

2.1 Import dependencies

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.9.RELEASE</version>
</parent>
<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
</dependencies>
Copy after login

2.2 Write the main program class

/**
 * @SpringBootApplication来标注一个主程序类
 * 说明这是一个Springboot应用
 */
@SpringBootApplication
public class HelloWorldMainApplication {
    public static void main(String[] args) {
        // 让Springboot运行起来
        SpringApplication.run(HelloWorldMainApplication.class,args);
    }
}
Copy after login

2.3 Write the controller layer

@Controller
public class HelloController {

    @RequestMapping("/hello")
    @ResponseBody
    public String hello() {
        return "hello";
    }
}
Copy after login

2.4 Run the main program Program

After the main program is started, enter http://localhost:8080/hello

Springboot project deployment method

2.5 Deployment project

Add a jar package plug-in to pom.xml, and then package it in the maven lifecycle. Then there will be a jar file in the target directory, copy it to the folder, and then use java -java xxx in the command window. The jar is deployed successfully.

<!-- 这个插件,可以将应用打包成一个可执行的jar包;-->
<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>
Copy after login

3 Use spring Initializr to quickly create Springboot

Springboot project deployment method

Springboot project deployment methodSpringboot project deployment method

Springboot project deployment method##

The above is the detailed content of Springboot project deployment method. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template