创建一个简单的 Springboot web项目

1、点击Project

创建一个简单的 Springboot web项目_第1张图片

2、点击 Next

创建一个简单的 Springboot web项目_第2张图片

3、项目名

创建一个简单的 Springboot web项目_第3张图片

4、web 项目

创建一个简单的 Springboot web项目_第4张图片

4、确认

创建一个简单的 Springboot web项目_第5张图片

5、pom.xml


    4.0.0
    
        org.springframework.boot
        spring-boot-starter-parent
        2.1.5.RELEASE
         
    
    com.example
    moneyer
    0.0.1-SNAPSHOT
    moneyer
    Demo project for Spring Boot

    
        1.8
    

    
        
            org.springframework.boot
            spring-boot-starter-web
        

        
            org.springframework.boot
            spring-boot-starter-test
            test
        
    

    
        
            
                org.springframework.boot
                spring-boot-maven-plugin
            
        
    


6、启动类

package com.example.moneyer;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class MoneyerApplication {

    public static void main(String[] args) {
        SpringApplication.run(MoneyerApplication.class, args);
    }

}

7、Controller类

package com.example.moneyer;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UserController {

    @RequestMapping("/hello")
    public  String  login(){
        return "hello world!!";
    }
    @RequestMapping("closed")
    public String  close(){
        return "This door is closed!";
    }
}

8、启动项目

"C:\Program Files\Java\jdk1.8.0_181\bin\java.exe"...

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.1.5.RELEASE)

2019-06-03 20:04:01.853  INFO 3320 --- [           main] com.example.moneyer.MoneyerApplication   : Starting MoneyerApplication on DESKTOP-LLVMBMQ with PID 3320 (C:\Users\dell\IdeaProjects\moneyer\target\classes started by dell in C:\Users\dell\IdeaProjects\moneyer)
2019-06-03 20:04:01.857  INFO 3320 --- [           main] com.example.moneyer.MoneyerApplication   : No active profile set, falling back to default profiles: default
2019-06-03 20:04:03.241  INFO 3320 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2019-06-03 20:04:03.266  INFO 3320 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2019-06-03 20:04:03.266  INFO 3320 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.19]
2019-06-03 20:04:03.363  INFO 3320 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2019-06-03 20:04:03.363  INFO 3320 --- [           main] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 1448 ms
2019-06-03 20:04:03.537  INFO 3320 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2019-06-03 20:04:03.693  INFO 3320 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2019-06-03 20:04:03.695  INFO 3320 --- [           main] com.example.moneyer.MoneyerApplication   : Started MoneyerApplication in 2.619 seconds (JVM running for 3.568)

9、效果

  1)http://localhost:8080/hello

   

  2)http://localhost:8080/closed

   

你可能感兴趣的:(创建一个简单的 Springboot web项目)