Spring Boot实践应用开发(5)
来源:互联网 发布:淘宝网页导航条的尺寸 编辑:程序博客网 时间:2024/06/03 15:58
用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.8targetCompatibility = 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:\Users\shin\.gradle,shin为计算机用户名,请按实际用户名修改)
-javaagent:C:\Users\shin\.gradle\caches\modules-2\files-2.1\org.springframework\springloaded\1.2.4.RELEASE\903fb9c6a6a93326dc4e89731d584faebd6bd435/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:\workspace\first\bin started by shin in E:\workspace\first)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 hierarchy2015-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 Tomcat2015-09-27 22:18:18.792 INFO 2680 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.0.262015-09-27 22:18:18.894 INFO 2680 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext2015-09-27 22:18:18.895 INFO 2680 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 3353 ms2015-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 hierarchy2015-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 startup2015-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里输入URL,http://localhost:8080/
在FirstExample.java的第12行设上断点后,会跳转到调试(debug)页面。
打包完程序的下载地址,http://pan.baidu.com/s/1o6spOJS,third.zip。
(注:Project名由first改为sample)
- Spring Boot实践应用开发(5)
- Spring Boot实践应用开发(1)
- Spring Boot实践应用开发(2)
- Spring Boot实践应用开发(3)
- Spring Boot实践应用开发(4)
- Spring Boot实践应用开发(6)
- Spring Boot实践应用开发(7)
- Spring Boot实践应用开发(8)
- Spring Boot实践应用开发(9)
- Spring Boot实践应用开发(10)
- Spring Boot实践应用开发(11)
- spring boot开发web应用
- Spring Boot开发Web应用
- Spring Boot: 开发web 应用
- Spring Boot: 开发web 应用
- Spring Boot: 开发web 应用
- Spring Boot: 开发web 应用
- Spring Boot: 开发web 应用
- 基于 Eclipse 平台的代码生成技术
- 从上到下遍历二叉树--20150925
- Lecture5-1Recap and Preview
- Hybris fraud report(欺诈订单功能) 拆解
- ocp-v13-011
- Spring Boot实践应用开发(5)
- OCP-V13-012
- 文章标题
- OpenGL函数思考-glHint
- 傀儡之城——摘要
- 个人学习笔记---linux文件系统
- OCP-V13-013
- 记一次tomcat web应用压测调优
- android中fragment实现底部标签页的切换