Home  >  Article  >  Java  >  How to start the main function in springboot project

How to start the main function in springboot project

PHPz
PHPzforward
2023-05-19 14:13:062923browse

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);
    }
}

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);
    }
}

@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!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete