使用eclipse快速新建spirngboot项目的方法
分享两种eclipse创建spirngboot项目的办法:
方案一:创建maven项目后修改pom文件
1.用eclipse创建简单的maven项目
2.修改pom文件
4.0.0 com.chry studySpringBoot 0.0.1-SNAPSHOT 1.7 org.springframework.boot spring-boot-starter-parent 1.4.0.RELEASE org.springframework.boot spring-boot-starter-web studySpringBoot
3.新建一个类文件
packagecom.chry.study; importorg.springframework.boot.SpringApplication; importorg.springframework.boot.autoconfigure.EnableAutoConfiguration; importorg.springframework.stereotype.Controller; importorg.springframework.web.bind.annotation.RequestMapping; importorg.springframework.web.bind.annotation.ResponseBody; @Controller @EnableAutoConfiguration publicclassSampleController{ @RequestMapping("/") @ResponseBody Stringhome(){ return"HelloWorld!"; } publicstaticvoidmain(String[]args)throwsException{ SpringApplication.run(SampleController.class,args); } }
说明:
1.spring-boot-starter-parent:
springboot官方推荐的maven管理工具,最简单的做法就是继承它。spring-boot-starter-parent包含了以下信息:
- 缺省使用java6编译,如果需要改为java1.7,则在pom中加上java.version属性即可
- 使用utf-8编码
- 实现了通用的测试框架(JUnit,Hamcrest,Mockito).
- 智能资源过滤
- 智能的插件配置(execplugin,surefire,GitcommitID,shade).
2.spring-boot-starter-web
springboot内嵌的WEB容器,缺省会使用tomcat
方案二:在eclipse上安装STS插件
1、Help->EclipseMarketplace
Search或选择“Popular”标签,选择SpringToolSuite(STS)forEclipse插件,安装或者谷歌百度搜索
2、newproject->输入spring下面会有提示选择SpringStarterProject
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持毛票票。