eclipse中创建springboot demo
来源:互联网 发布:midi伴奏制作软件 编辑:程序博客网 时间:2024/06/05 19:34
1创建一个maven工程
2编辑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.springboot.test</groupId> <artifactId>stringbootDemo</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging> <name>stringbootDemo</name> <url>http://maven.apache.org</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <!-- Inherit defaults from Spring Boot --> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.4.0.BUILD-SNAPSHOT</version> </parent> <!-- Add typical dependencies for a web application --> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> </dependencies> <!-- Package as an executable jar --> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> <!-- Add Spring repositories --> <!-- (you don't need this if you are using a .RELEASE version) --> <repositories> <repository> <id>spring-snapshots</id> <url>http://repo.spring.io/snapshot</url> <snapshots><enabled>true</enabled></snapshots> </repository> <repository> <id>spring-milestones</id> <url>http://repo.spring.io/milestone</url> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>spring-snapshots</id> <url>http://repo.spring.io/snapshot</url> </pluginRepository> <pluginRepository> <id>spring-milestones</id> <url>http://repo.spring.io/milestone</url> </pluginRepository> </pluginRepositories> </project>
3 编制Application.java
package com.springboot.test.stringbootDemo;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.EnableAutoConfiguration;import org.springframework.boot.autoconfigure.SpringBootApplication;import org.springframework.context.annotation.ComponentScan;import org.springframework.context.annotation.Configuration;//@SpringBootApplication //该方式在此配置中不好使,需使用下面三个组件@Configuration@ComponentScan@EnableAutoConfigurationpublic class Application { public static void main(String[] args) { // TODO Auto-generated method stub SpringApplication.run(Application.class, args); }}
4 编制Example.java
package com.springboot.test.stringbootDemo;import org.springframework.boot.autoconfigure.EnableAutoConfiguration;import org.springframework.web.bind.annotation.PathVariable;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RestController;@RestController@EnableAutoConfigurationpublic class Example { @RequestMapping("/") String home(){ return "hello world"; } @RequestMapping("/haha/{myName}") String index(@PathVariable String myName){ return "hello ... + " + myName+"!!!"; }}
5 选中项目 maven-update
6 选中项目 右键- run as -Java Application—控制台打印springboot启动日志
7 浏览器 输入 localhost:8080 出现
阅读全文
1 0
- eclipse中创建springboot demo
- eclipse中创建springboot项目
- Eclipse中创建新的SpringBoot项目
- eclipse+maven+springboot小Demo
- SpringBoot+Gradle运行简单Demo Eclipse
- eclipse创建Hibernate Demo中需要注意的地方
- eclipse中springboot报错
- idea中创建springboot项目
- [SpringBoot]如何创建一个SpringBoot项目 By Eclipse
- eclipse下载springboot插件到创建springboot项目
- Eclipse安装Springboot并创建Web项目
- 关于IDEA中创建springboot+security+jpa
- SpringBoot + Maven之Demo
- SpringBoot -- Kafka(二) Demo
- SpringBoot + RabbitMQ 使用Demo
- SpringBoot first Demo
- SpringBoot -- Kafka(二) Demo
- SpringBoot入门demo(一)
- Android使用handler实现简单的定时器,主线程每秒刷新UI
- HDU 5015 233 Matrix --矩阵快速幂
- CSS中margin和padding的区别
- 【Linux-nfs服务器】挂载后无法显示目录内容的情况之一
- 屏幕抓取和其他实用程序
- eclipse中创建springboot demo
- unity下载
- caffe随记(八)---使用caffe训练FCN的pascalcontext-fcn32s模型(pascal-context数据集)
- SQL语句详细汇总
- Android 监听ConentProvider的数据改变,ContentObserver
- 解决Ueditor编辑器图片保存路径问题
- Jenkins 2.19.4默认没有Launch agent via Java Web Start,可通过以下来设置:
- 排序算法及实现
- js数据结构之链表