Spring Boot实践应用开发(5) - Go语言中文社区

Spring Boot实践应用开发(5)




eclipse执行(run)和调试(debug) spring boot

1,下载first.zip项目,下载地址http://pan.baidu.com/s/1o6spOJS

解压导入到eclipse中。

 

2,修改build.gradle文件。主要追加和修改以下定义。

  

classpath("org.springframework:springloaded:1.2.4.RELEASE")

 

def springBootVersion = '1.2.6.RELEASE'

compile("org.springframework.boot:spring-boot-starter-web:${springBootVersion}")

compile("org.springframework:springloaded:1.2.4.RELEASE")


完整的代码如下。

buildscript {

    repositories {

        jcenter()

        maven { url "http://repo.spring.io/snapshot" }

        maven { url "http://repo.spring.io/milestone" }

    }

    dependencies {

        classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.6.RELEASE")

        classpath("org.springframework:springloaded:1.2.4.RELEASE")

    }

}

 

apply plugin: 'java'

apply plugin: 'eclipse'

apply plugin: 'spring-boot'

 

jar {

    baseName = 'first'

    version =  '0.1.0'

}

 

repositories {

    jcenter()

    maven { url "http://repo.spring.io/snapshot" }

    maven { url "http://repo.spring.io/milestone" }

}

 

sourceCompatibility = 1.8

targetCompatibility = 1.8

 

dependencies {

           def springBootVersion = '1.2.6.RELEASE'

    compile("org.springframework.boot:spring-boot-starter-web:${springBootVersion}")

    compile("org.springframework:springloaded:1.2.4.RELEASE")

    testCompile("org.springframework.boot:spring-boot-starter-test")

}

 

task wrapper(type: Wrapper) {

    gradleVersion = '2.3'

}

 

3,在项目根目录下执行 gradlew eclipse

 


4,FirstExample.java点击右键,Run as -> RunAs Configurations… , 然后双击Java Application,自动生成以FirstExample命名的项目。

点击Arguments标签,在VM arguments里记入springloaded-1.2.4.RELEASE.jar的配置信息。(C:Usersshin.gradleshin为计算机用户名,请按实际用户名修改)

-javaagent:C:Usersshin.gradlecachesmodules-2files-2.1org.springframeworkspringloaded1.2.4.RELEASE903fb9c6a6a93326dc4e89731d584faebd6bd435/springloaded-1.2.4.RELEASE.jar-noverify

 

 

 

 

5,点击Run,程序就执行了。最后出现Started FirstExample in ***seconds,说明执行成功。

 

  .   ____          _            __ _ _

 /\ / ___'_ __ _ _(_)_ __  __ _    

( ( )___ | '_ | '_| | '_ / _` |    

 \/  ___)| |_)| | | | | || (_| |  ) ) ) )

  '  |____| .__|_| |_|_| |___, | / / / /

 =========|_|==============|___/=/_/_/_/

 :: Spring Boot ::        (v1.2.6.RELEASE)

 

2015-09-27 22:18:15.399  INFO 2680 --- [           main] org.com.first.FirstExample               : Starting FirstExample on shin-PC with PID 2680 (E:workspacefirstbin started by shin in E:workspacefirst)

2015-09-27 22:18:15.543  INFO 2680 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@4e718207: startup date [Sun Sep 27 22:18:15 PDT 2015]; root of context hierarchy

2015-09-27 22:18:16.264  INFO 2680 --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Overriding bean definition for bean 'beanNameViewResolver': replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter.class]]

2015-09-27 22:18:18.337  INFO 2680 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)

2015-09-27 22:18:18.791  INFO 2680 --- [           main] o.apache.catalina.core.StandardService   : Starting service Tomcat

2015-09-27 22:18:18.792  INFO 2680 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.0.26

2015-09-27 22:18:18.894  INFO 2680 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext

2015-09-27 22:18:18.895  INFO 2680 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 3353 ms

2015-09-27 22:18:19.507  INFO 2680 --- [ost-startStop-1] o.s.b.c.e.ServletRegistrationBean        : Mapping servlet: 'dispatcherServlet' to [/]

2015-09-27 22:18:19.512  INFO 2680 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'characterEncodingFilter' to: [/*]

2015-09-27 22:18:19.513  INFO 2680 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]

2015-09-27 22:18:19.742  INFO 2680 --- [           main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@4e718207: startup date [Sun Sep 27 22:18:15 PDT 2015]; root of context hierarchy

2015-09-27 22:18:19.789  INFO 2680 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/]}" onto java.lang.String org.com.first.FirstExample.firsthome()

2015-09-27 22:18:19.791  INFO 2680 --- [           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)

2015-09-27 22:18:19.791  INFO 2680 --- [           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)

2015-09-27 22:18:19.824  INFO 2680 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]

2015-09-27 22:18:19.825  INFO 2680 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]

2015-09-27 22:18:19.873  INFO 2680 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]

2015-09-27 22:18:19.940  INFO 2680 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup

2015-09-27 22:18:20.014  INFO 2680 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)

2015-09-27 22:18:20.016  INFO 2680 --- [           main] org.com.first.FirstExample               : Started FirstExample in 4.978 seconds (JVM running for 6.292)

 

6,调试(debug)时,在调试功能里执行FirstExample

在IE里输入URLhttp://localhost:8080/

FirstExample.java的第12行设上断点后,会跳转到调试(debug)页面。

 

 

 

 

打包完程序的下载地址,http://pan.baidu.com/s/1o6spOJSthird.zip

(注:Project名由first改为sample)

版权声明:本文来源CSDN,感谢博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/engchina/article/details/48769789
站方申明:本站部分内容来自社区用户分享,若涉及侵权,请联系站方删除。
  • 发表于 2019-08-27 17:07:12
  • 阅读 ( 1402 )
  • 分类:Go应用

0 条评论

请先 登录 后评论

官方社群

GO教程

猜你喜欢