eclipse+maven+springboot小Demo
来源:互联网 发布:杭州淘宝学院 编辑:程序博客网 时间:2024/05/21 22:49
1、eclipse创建maven项目springbootstudy,创建成功后如图项目目录
File->other(ctrl+N)->maven项目->next下去
2、编写pom.xml文件
<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>springboot</groupId> <artifactId>springbootstudy</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging> <name>springbootstudy</name> <url>http://maven.apache.org</url><!-- spring boot 父节点依赖,引入这个之后相关的引入就不需要添加version配置,spring boot会自动选择最合适的版本进行添加。 --><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>1.4.0.RELEASE</version></parent> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <java.version>1.7</java.version> </properties> <dependencies> <!-- spring-boot-starter-web: MVC,AOP的依赖包.... --> <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web --><dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId></dependency><dependency> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> <version>2.4.3</version></dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <scope>test</scope> </dependency> </dependencies> <!-- 构建节点. --><build><plugins><!-- 在这里添加springloader plugin<plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin </artifactId> <dependencies> <dependency> <groupId>org.springframework</groupId> <artifactId>springloaded</artifactId> <version>1.2.4.RELEASE</version> </dependency> </dependencies> <executions> <execution> <goals> <goal>repackage</goal> </goals> <configuration> <classifier>exec</classifier> </configuration> </execution> </executions></plugin> --><!-- 这是spring boot devtool plugin --><plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <!--fork : 如果没有该项配置,肯呢个devtools不会起作用,即应用不会restart --> <fork>true</fork> </configuration> </plugin></plugins></build></project>3、创建编写控制类
package springboot.springbootstudy;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RestController;@RestControllerpublic class HelloController {/** * 在这里我们使用@RequestMapping 建立请求映射: http://127.0.0.1:8080/hello * * @return */@RequestMapping("/hello")public String hello() {return "你好springboot";}}4、编写启动类:使用@SpringBootApplication指定这是一个 spring boot的应用程序.
package springboot.springbootstudy;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;@SpringBootApplicationpublic class App {public static void main(String[] args) {/* * 在main方法进行启动我们的应用程序. */SpringApplication.run(App.class, args);}}
4、启动服务测试应用
A、执行App类的main方法 或 F11
B、利用http://127.0.0.1:8080/hello在浏览器访问测试
阅读全文
1 0
- eclipse+maven+springboot小Demo
- 使用springBoot框架+maven+mybatis 实现的小demo
- SpringBoot + Maven之Demo
- Maven构建springBoot Demo案例
- Maven搭建springboot项目demo
- SpringBoot 整合ActiveMQ 小Demo
- eclipse中创建springboot demo
- IntelliJ IDEA搭建SpringBoot的小Demo
- IntelliJ IDEA搭建SpringBoot的小Demo
- springboot整合redis缓存的小demo
- IntelliJ IDEA搭建SpringBoot的小Demo
- IntelliJ IDEA搭建SpringBoot的小Demo
- SpringBoot+Gradle运行简单Demo Eclipse
- Eclipse 使用 maven 构建demo
- eclipse+maven+cxf webservice demo
- maven笔记-3-springboot小案例
- eclipse 使用maven 构建springboot 程序
- eclipse 使用maven构建 springboot +swagger
- Python tuple
- Spring第一天
- 海思编解码芯片添加64M nor flash
- 基于比较的排序算法复杂度为nlg(n)的证明
- 【Linux排错】wget_insecurely
- eclipse+maven+springboot小Demo
- Python 条件判断
- 结构体内存对齐
- 结构体的字节对齐问题
- Vim编辑技巧
- 对隐式转换保持警觉
- Python 循环
- 初识servlet
- Python dict