分享两种eclipse创建spirngboot项目的办法:
方案一:创建maven项目后修改pom文件
1.用eclipse创建简单的maven项目
2.修改pom文件
<?xml version="1.0" encoding="utf-8"?> <project xmlns="http://maven.apache.org/pom/4.0.0" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://maven.apache.org/pom/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelversion>4.0.0</modelversion> <groupid>com.chry</groupid> <artifactid>studyspringboot</artifactid> <version>0.0.1-snapshot</version> <properties> <java.version>1.7</java.version> </properties> <!-- inherit defaults from spring boot --> <parent> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-starter-parent</artifactid> <version>1.4.0.release</version> </parent> <!-- add typical dependencies for a web application --> <dependencies> <dependency> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-starter-web</artifactid> </dependency> </dependencies> <!-- package as an executable jar --> <build> <finalname>studyspringboot</finalname> </build> </project>
3.新建一个类文件
package com.chry.study; import org.springframework.boot.springapplication; import org.springframework.boot.autoconfigure.enableautoconfiguration; import org.springframework.stereotype.controller; import org.springframework.web.bind.annotation.requestmapping; import org.springframework.web.bind.annotation.responsebody; @controller @enableautoconfiguration public class samplecontroller { @requestmapping("/") @responsebody string home() { return "hello world!"; } public static void main(string[] args) throws exception { springapplication.run(samplecontroller.class, args); } }
说明:
1.spring-boot-starter-parent:
springboot官方推荐的maven管理工具,最简单的做法就是继承它。 spring-boot-starter-parent包含了以下信息:
2.spring-boot-starter-web
springboot内嵌的web容器, 缺省会使用tomcat
方案二:在eclipse上安装sts插件
1、help -> eclipse marketplace
search或选择“popular”标签,选择spring tool suite (sts) for eclipse插件,安装 或者谷歌百度搜索
2、new project -> 输入spring 下面会有提示 选择spring starter project
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持移动技术网。
如对本文有疑问, 点击进行留言回复!!
springmvc之ResponseBody响应json数据遇到的错误及解决
uni-app 后台升级 静默升级 uniapp 后台更新 静默更新 在线升级
SpringBoot多Module启动报错Could not transfer metadata
Hibernate项目报错:Cannot call sendError() after the response has been committed
网友评论