SpringBoot环境搭建eclipse版和IntelliJ IDEA版
来源:互联网 发布:采购软件视频 编辑:程序博客网 时间:2024/05/16 12:38
首先来一个简单的。
IntelliJ IDEA版
IntelliJ IDEA 旗舰版中集成了SpringBoot的开发,所以在创建项目的时候就可以直接创建SpringBoot 项目
上面就将一个SringBoot的环境搭好了。下面把pom.xml贴出了
<?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.example</groupId><artifactId>springbootdemo</artifactId><version>0.0.1-SNAPSHOT</version><packaging>jar</packaging><name>springbootdemo</name><description>Demo project for Spring Boot</description><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>1.5.6.RELEASE</version><relativePath/> <!-- lookup parent from repository --></parent><properties><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding><java.version>1.8</java.version></properties><dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency></dependencies><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin></plugins></build></project>
SpringbootdemoApplication 是核心类,需要使用它进行启动SpringBoot
package com.example.springbootdemo;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;/*@SpringBootApplication SpringBoot 启动必须的* */@SpringBootApplicationpublic class SpringbootdemoApplication {public static void main(String[] args) {SpringApplication.run(SpringbootdemoApplication.class, args);}}
最后一个Controller 用于测试
package com.example.springbootdemo;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RestController;@RestControllerpublic class HelloController { @RequestMapping("/hello") public String sayHello(){ return "hello world"; }}
启动完成进行测试
至此IntelliJ IDEA版 第一个SpringBoot项目成功搭建
下面是eclipse 搭建
首先搭建正常搭建一个Maven项目。可以参考http://blog.csdn.net/qq_34160679/article/details/76461081
搭建完Maven项目后,进入pom.xml 进行SpringBoot 的设置
下面贴出pom.xml(eclipse版)
<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/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.nyist</groupId> <artifactId>FirstSpringBoot</artifactId> <packaging>war</packaging> <version>0.0.1-SNAPSHOT</version> <name>FirstSpringBoot Maven Webapp</name> <url>http://maven.apache.org</url> <parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>1.5.6.RELEASE</version><relativePath/> <!-- lookup parent from repository --></parent><properties><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding><java.version>1.8</java.version></properties><dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency></dependencies> <build> <finalName>FirstSpringBoot</finalName> </build></project>然后可以在一个包中创建一个Controller 用来设置SpringBoot的启动和访问路径之后的响应。
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@EnableAutoConfigurationpublic class SampleController { @RequestMapping("/") @ResponseBody String home() { return "Hello World!"; } public static void main(String[] args) throws Exception { SpringApplication.run(SampleController.class, args); }}最后执行Controller中main函数使用 Java Application
阅读全文
1 0
- SpringBoot环境搭建eclipse版和IntelliJ IDEA版
- IntelliJ IDEA搭建SpringBoot
- IntelliJ IDEA搭建SpringBoot应用
- IntelliJ IDEA搭建SpringBoot应用
- IntelliJ IDEA搭建SpringBoot应用
- IntelliJ IDEA环境搭建
- spark Intellij IDEA及eclipse开发环境搭建
- SpringBoot(1) 使用Intellij IDEA社区版构建SpringBoot项目
- IntelliJ IDEA搭建SpringBoot的小Demo
- IntelliJ IDEA搭建SpringBoot的小Demo
- IntelliJ IDEA搭建SpringBoot的小Demo
- IntelliJ IDEA搭建SpringBoot的小Demo
- IntelliJ IDEA和Eclipse
- IntelliJ IDEA搭建Spring环境
- Kotlin IntelliJ IDEA环境搭建
- 从头搭建IntelliJ IDEA环境
- SpringBoot + MyBatis + MySQL + Maven在Intellij IDEA下开发环境的搭建
- intellij idea 搭建scala环境和一些问题
- 杂谈
- poj 2566 Bound Found 尺取法 / lower_bound
- Django建教育平台(六)--首页和登录页面配置
- UVALive 6886 Golf Bot 桶排+剪枝
- CentOS 使用yum命令安装出现错误提示:Loaded plugins: fastestmirror, refresh-packagekit, security
- SpringBoot环境搭建eclipse版和IntelliJ IDEA版
- 各种排序
- 最大流增广路
- luoguP2831 愤怒的小鸟
- 数据预处理之特征选择
- 鸟叔Linux学习笔记:第一章 Linux是什么与如何学习
- 使用Java网络编程创建基于UDP协议的Server和Client
- 多项式与快速傅里叶变换
- 数据库CRUD增删改查操作模拟