Spring Boot实践应用开发(5)
2015-09-27 21:49
375 查看
用eclipse执行(run)和调试(debug)
spring boot
1,下载first.zip项目,下载地址http://pan.baidu.com/s/1o6spOJS。
解压导入到eclipse中。
2,修改build.gradle文件。主要追加和修改以下定义。
完整的代码如下。
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,说明执行成功。
6,调试(debug)时,在调试功能里执行FirstExample。
在IE里输入URL,http://localhost:8080/
在FirstExample.java的第12行设上断点后,会跳转到调试(debug)页面。
打包完程序的下载地址,http://pan.baidu.com/s/1o6spOJS,third.zip。
(注:Project名由first改为sample)
用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:\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 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里输入URL,http://localhost:8080/
在FirstExample.java的第12行设上断点后,会跳转到调试(debug)页面。
打包完程序的下载地址,http://pan.baidu.com/s/1o6spOJS,third.zip。
(注:Project名由first改为sample)
相关文章推荐
- 基于 Eclipse 平台的代码生成技术
- 论JAVA项目对头脑的锻炼程度
- Java工具类(三) 解析配置文件工具类
- JFreeChart(与Struts2整合)
- Java中转换流的相关用法
- netbeans表的录入与清除
- Spring事务编写
- 设计模式之单例模式(java)
- JAVAWEB学习
- java SE复习笔记50
- java SE复习笔记49
- java SE复习笔记48
- java SE复习笔记47
- java SE复习笔记46
- java SE复习笔记45
- java SE复习笔记44
- Eclipse-Mars Release (4.5.0)创建Maven项目报错
- java SE复习笔记43
- java SE复习笔记42
- java SE复习笔记41