sprint boot 自动创建web应用(3)

1. springboot自动创建地址:https://start.spring.io/

2.选择web(springMVC)

3.点击创建

4.创建成功

5.解压,导入项目

 

 6.新建成功

 7.原因 : maven的插件版本的问题,造成与IDE的不兼容

解决办法 :在pom中加上 <maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>就可以了

    <properties>
        <java.version>1.8</java.version>
        <spring-cloud.version>Greenwich.SR1</spring-cloud.version>
        <maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
    </properties>

 8.项目右键-maven-updata project

 

9.启动项目

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

2019-11-03 12:51:06.730  INFO 7196 --- [           main] c.x.springboot.ControllerApplication     : Starting ControllerApplication on PC-20190411SFOQ with PID 7196 (D:\Downloads\com.xiaobing.springboot_v1\target\classes started by Administrator in D:\Downloads\com.xiaobing.springboot_v1)
2019-11-03 12:51:06.752  INFO 7196 --- [           main] c.x.springboot.ControllerApplication     : No active profile set, falling back to default profiles: default
2019-11-03 12:51:22.173  INFO 7196 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2019-11-03 12:51:23.416  INFO 7196 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2019-11-03 12:51:23.417  INFO 7196 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.27]
2019-11-03 12:51:24.883  INFO 7196 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2019-11-03 12:51:24.884  INFO 7196 --- [           main] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 17724 ms
2019-11-03 12:51:26.409  INFO 7196 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2019-11-03 12:51:30.032  INFO 7196 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2019-11-03 12:51:30.049  INFO 7196 --- [           main] c.x.springboot.ControllerApplication     : Started ControllerApplication in 27.012 seconds (JVM running for 31.285)

10.web访问

 11.新建class映射类

package com.xiaobing.springboot;

import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@SpringBootApplication
public class Example {

    @RequestMapping("/")
    String home() {
        return "Hello World!";
    }
}

12.重新启动项目

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

2019-11-03 13:01:44.699  INFO 7192 --- [           main] c.x.springboot.ControllerApplication     : Starting ControllerApplication on PC-20190411SFOQ with PID 7192 (D:\Downloads\com.xiaobing.springboot_v1\target\classes started by Administrator in D:\Downloads\com.xiaobing.springboot_v1)
2019-11-03 13:01:44.712  INFO 7192 --- [           main] c.x.springboot.ControllerApplication     : No active profile set, falling back to default profiles: default
2019-11-03 13:01:48.641  INFO 7192 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2019-11-03 13:01:48.711  INFO 7192 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2019-11-03 13:01:48.712  INFO 7192 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.27]
2019-11-03 13:01:49.121  INFO 7192 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2019-11-03 13:01:49.122  INFO 7192 --- [           main] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 4166 ms
2019-11-03 13:01:49.694  INFO 7192 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2019-11-03 13:01:50.262  INFO 7192 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2019-11-03 13:01:50.272  INFO 7192 --- [           main] c.x.springboot.ControllerApplication     : Started ControllerApplication in 6.845 seconds (JVM running for 8.017)

13.访问web项目

 日志打印

2019-11-03 13:02:51.079  INFO 7192 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
2019-11-03 13:02:51.080  INFO 7192 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2019-11-03 13:02:51.107  INFO 7192 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 26 ms

14.学习总结,后续完善!

posted @ 2019-11-03 13:04  o小兵o  阅读(503)  评论(0编辑  收藏  举报