spring-boot初尝试
来源:互联网 发布:质量问题淘宝怎么陪 编辑:程序博客网 时间:2024/05/16 14:46
本文章资料包(demo和文档):http://pan.baidu.com/s/1qYnhJwo
进入源码目录,执行gradle eclipse命令后,导入项目到eclipse
package com.lypp.controller;import org.springframework.boot.SpringApplication;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; //@EnableAutoConfiguration@RestController@RequestMapping("/user")public class UserController { @RequestMapping("/{id}") public Object view(@PathVariable("id") Long id) { return "hello"+id; } public static void main(String[] args) { SpringApplication.run(UserController.class); }}
启动文件必须位于package中,不能放到默认package下
package com.lypp;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.EnableAutoConfiguration;import org.springframework.context.annotation.ComponentScan;import org.springframework.context.annotation.Configuration;@Configuration@EnableAutoConfiguration@ComponentScan public class Application { public static void main(String[] args) { SpringApplication.run(Application.class,args); } }
构建文件:
apply plugin: 'jetty'apply plugin: 'war'apply plugin: 'java'apply plugin: 'eclipse'apply plugin: 'eclipse-wtp' sourceSets { main { java { srcDir 'src/main/java' } resources { srcDir 'src/main/resources' } } } task cleanEclipseOutput(type: Delete) { delete eclipse.classpath.defaultOutputDir } //创建源码目录 task createSource { sourceSets*.java.srcDirs*.each { it.mkdirs() } sourceSets*.resources.srcDirs*.each { it.mkdirs() } } eclipse { classpath { defaultOutputDir =file('build/eclipse') } } [compileJava, compileTestJava,javadoc]*.options.collect { options -> options.encoding = 'UTF-8' }dependencies { compile "org.springframework.boot:spring-boot-starter-web:1.4.2.RELEASE" // compile("org.springframework.boot:spring-boot-starter-web:1.4.2.RELEASE") }repositories { maven { url 'http://192.168.0.110:8082/nexus/content/groups/public' } mavenCentral name: "mc", artifactUrls: ["http://maven.oschina.net/content/groups/public","http://repository.apache.org/snapshots/"] }
相关截图如下:
访问:http://localhost:8080/user/1
0 0
- spring-boot初尝试
- Spring AOP初尝试
- Spring JDBC初尝试
- 我的Spring初尝试
- 【Spring】Spring oxm 入门初尝试
- Spring Boot 初体验
- Spring-Boot初体验
- spring boot 初体验
- Spring Boot初体验
- Spring Boot初体验
- Spring Boot初体验
- Spring-boot初使用
- spring boot 初体验
- 【Spring Boot】Spring Boot
- spring boot之初体验
- Spring Boot Spring Aop初接触
- 第一次DWR+Spring尝试
- spring boot
- Android性能优化之Listview(ViewHolder重用机制)
- adb不是内部或外部命令,也不是可运行的程序
- H5在微信公众号的下拉刷新实现
- solaris 5.10 rac 11.2.0.4 安装
- 卡尔曼滤波器算法浅析及matlab实战
- spring-boot初尝试
- 正则表达式的简单使用
- code
- [CF721C]Journey
- Maven的POM文件详解
- 复数字符串资源中文总是获得quantity为other的字符串
- 运算放大器输入过压保护:箝位与集
- python之连接mysql
- h5本地存储localStorage,sessionStorage