码迷,mamicode.com
首页 > 编程语言 > 详细

spring-boot环境搭建

时间:2018-01-25 12:02:15      阅读:279      评论:0      收藏:0      [点我收藏+]

标签:pid   5.7   target   web   set   href   exec   arch   hid   

1、下载:spring-tool-suite-3.9.2.RELEASE-e4.7.2-win32-x86_64
http://spring.io/tools/sts/all
解压后点击
技术分享图片

配置Maven
技术分享图片

新建项目:
技术分享图片
输入项目名称:
技术分享图片

输入web
技术分享图片
显示成功:
技术分享图片

新建类:
技术分享图片

类里编写:

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

@RestController
public class Hello {

    @RequestMapping(value="/helloworld")
    public String helloWorld() {
        return "hello world";
    }

}

启动,并且访问:
技术分享图片

 .   ____          _            __ _ _
 /\\ / ___‘_ __ _ _(_)_ __  __ _ \ \ \ ( ( )\___ | ‘_ | ‘_| | ‘_ \/ _` | \ \ \  \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  ‘  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.5.9.RELEASE)

2018-01-25 11:07:54.340  INFO 2696 --- [           main] com.example.demo.DemoApplication         : Starting DemoApplication on liwen-pc with PID 2696 (D:\TOOL\sptingspcae\demo\target\classes started by lw in D:\TOOL\sptingspcae\demo)
2018-01-25 11:07:54.344  INFO 2696 --- [           main] com.example.demo.DemoApplication         : No active profile set, falling back to default profiles: default
2018-01-25 11:07:54.406  INFO 2696 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@6366ebe0: startup date [Thu Jan 25 11:07:54 CST 2018]; root of context hierarchy
2018-01-25 11:07:55.778  INFO 2696 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2018-01-25 11:07:55.790  INFO 2696 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2018-01-25 11:07:55.791  INFO 2696 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.23
2018-01-25 11:07:55.872  INFO 2696 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2018-01-25 11:07:55.872  INFO 2696 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 1470 ms
2018-01-25 11:07:56.038  INFO 2696 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Mapping servlet: ‘dispatcherServlet‘ to [/]
2018-01-25 11:07:56.043  INFO 2696 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: ‘characterEncodingFilter‘ to: [/*]
2018-01-25 11:07:56.044  INFO 2696 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: ‘hiddenHttpMethodFilter‘ to: [/*]
2018-01-25 11:07:56.044  INFO 2696 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: ‘httpPutFormContentFilter‘ to: [/*]
2018-01-25 11:07:56.044  INFO 2696 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: ‘requestContextFilter‘ to: [/*]
2018-01-25 11:07:56.429  INFO 2696 --- [           main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@6366ebe0: startup date [Thu Jan 25 11:07:54 CST 2018]; root of context hierarchy
2018-01-25 11:07:56.507  INFO 2696 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/user]}" onto public com.example.demo.bean.User com.example.demo.web.HelloWorldController.getUser()
2018-01-25 11:07:56.508  INFO 2696 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/helloworld]}" onto public java.lang.String com.example.demo.web.HelloWorldController.helloWorld()
2018-01-25 11:07:56.513  INFO 2696 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2018-01-25 11:07:56.513  INFO 2696 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2018-01-25 11:07:56.556  INFO 2696 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-01-25 11:07:56.557  INFO 2696 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-01-25 11:07:56.620  INFO 2696 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-01-25 11:07:56.801  INFO 2696 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2018-01-25 11:07:56.891  INFO 2696 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2018-01-25 11:07:56.896  INFO 2696 --- [           main] com.example.demo.DemoApplication         : Started DemoApplication in 2.828 seconds (JVM running for 3.859)
2018-01-25 11:10:44.860  INFO 2696 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring FrameworkServlet ‘dispatcherServlet‘
2018-01-25 11:10:44.860  INFO 2696 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet ‘dispatcherServlet‘: initialization started
2018-01-25 11:10:44.878  INFO 2696 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet ‘dispatcherServlet‘: initialization completed in 17 ms

显示成功:
技术分享图片

spring-boot环境搭建

标签:pid   5.7   target   web   set   href   exec   arch   hid   

原文地址:http://blog.51cto.com/357712148/2064950

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!