Home > Java > Java Tutorial > body text

How to start the main function in springboot project

PHPz
Release: 2023-05-19 14:13:06
forward
2922 people have browsed it

springboot project main function startup

Create a new appController class under the controller package

How to start the main function in springboot project

package controller;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
@SpringBootApplication
public class appController extends SpringBootServletInitializer {
    public static void main(String[] args){
        SpringApplication.run(appController.class,args);
    }
    
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(appController.class);
    }
}
Copy after login

Test:

New indexController

How to start the main function in springboot project

Create a new proController class

How to start the main function in springboot project

#Start the main function in the appController class

Browser input: localhost:8080 /proo

Browser input: localhost:8080/index

How to start the main function in springboot project

How to start the main function in springboot project

##Detailed explanation of SpringBoot main method

 @SpringBootApplication
public class UdeamApplication { 
    public static void main(String[] args) {
        SpringApplication.run(UdeamApplication.class, args);
    }
}
Copy after login

@SpringBootApplication

Enable springboot configuration annotation, project startup entry, used to start spring container, start tomcat, other packages must be in the same level directory or sub-package as this class

How to start the main function in springboot project

The above is the detailed content of How to start the main function in springboot project. 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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!