Intellij和SpringBoot,gradle构建Hello world!工程
来源:互联网 发布:淘宝v2贷款无视黑白户 编辑:程序博客网 时间:2024/04/29 16:07
参考
https://spring.io/guides/gs/spring-boot/
首先下载Intellij,然后
(1)新建一个工程:
package com.example;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.EnableAutoConfiguration;import org.springframework.boot.autoconfigure.SpringBootApplication;import org.springframework.context.ApplicationContext;import org.springframework.context.annotation.ComponentScan;import org.springframework.context.annotation.Configuration;import java.util.Arrays;@SpringBootApplicationpublic class DaoTestApplication {public static void main(String[] args) {ApplicationContext ctx = SpringApplication.run(DaoTestApplication.class, args);System.out.println("Let's inspect the beans provided by Spring Boot:");String[] beanNames = ctx.getBeanDefinitionNames();Arrays.sort(beanNames);for (String beanName : beanNames) {System.out.println(beanName);}}}
package com.example;import org.springframework.web.bind.annotation.RestController;import org.springframework.web.bind.annotation.RequestMapping;@RestControllerpublic class HelloController { @RequestMapping("/") public String index() { return "Hello world!"; }}
buildscript {ext {springBootVersion = '1.4.0.RELEASE'}repositories {mavenCentral()}dependencies {classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")}}apply plugin: 'java'apply plugin: 'eclipse'apply plugin: 'spring-boot'jar {baseName = 'daotest'version = '0.0.1-SNAPSHOT'}sourceCompatibility = 1.8targetCompatibility = 1.8repositories {mavenCentral()}dependencies {// tag::jetty[]compile("org.springframework.boot:spring-boot-starter-web") {exclude module: "spring-boot-starter-tomcat"}compile("org.springframework.boot:spring-boot-starter-jetty")// end::jetty[]// tag::actuator[]compile("org.springframework.boot:spring-boot-starter-actuator")// end::actuator[]testCompile("junit:junit")testCompile('org.springframework.boot:spring-boot-starter-test')task wrapper(type: Wrapper) {gradleVersion = '2.3'}}eclipse {classpath { containers.remove('org.eclipse.jdt.launching.JRE_CONTAINER') containers 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8'}}
编译运行:
注意:需要设置JDK8,这个地方我设置少了,卡了蛮久的。
Java JDK 8 在 Windows 8.1下的安装以及环境变量的配置
在Windows 中,双击安装就是。
Win8.1下JDK8环境变量的配置:
依次单击计算机(Computer),选择属性(Properties),选择高级系统设置(Advanced systems settings), 选择环境变量(Environment Variables).
新建3个环境变量(PATH,CLASSPATH, JAVA_HOME),若有则不用新建。
给3个环境变量增加相应的值(由Java所在的路径决定,根据具体情况修改),例如:
PATH D:\Program Files\Java\jdk1.8.0\bin; D:\Program Files\Java\jdk1.8.0\jre\bin
CLASSPATH D:\Program Files\Java\jdk1.8.0\lib; D:\Program Files\Java\jdk1.8.0\lib\tools.jar
JAVA_HOME D:\Program Files\Java\jdk1.8.0
不同路径之间用分号隔开。
若添加正确,注销或重启计算机以后,在PowerShell或cmd中输入:
java -version
javac -version
都会显示相应的版本信息。
0 0
- Intellij和SpringBoot,gradle构建Hello world!工程
- 使用 IntelliJ IDEA + Gradle + SpringBoot 搭建Hello World工程
- 使用 IntelliJ IDEA + Gradle + SpringBoot 搭建Hello World工程
- gradle 构建 hello world
- gradle, springboot,cfx-- Hello World
- Gradle-使用Gradle构建和测试-1-Hello,Gradle
- SpringBoot的 Hello World
- 使用Gradle构建SpringBoot工程系列:第一篇:Gradle及SpringBoot简介
- 使用Gradle构建SpringBoot工程系列:第一篇:Gradle及SpringBoot简介
- Gradle hello world 脚本
- 【2】Gradle:“Hello World!”
- JNI工程Hello World!
- SpringBoot(一) 工具安装和hello world示例
- 使用Gradle构建SpringBoot工程系列:第六篇:SpringBoot 替换Tomcat为Jetty或UnderTow
- 使用gradle构建springboot工程的以及部署springboot到linux服务
- SpringBoot入门:Hello World(一)
- SpringBoot笔记之Hello World
- SpringBoot框架搭建 Hello World
- 344. Reverse String
- iOS实现一个简单的视频播放器
- Linux GIT 的使用方法详解
- 牛课网刷题--剑指offer(二维数组中的查找)
- 指针
- Intellij和SpringBoot,gradle构建Hello world!工程
- infragistics 实例化新行
- 装饰器 decorator
- IPC的6种方式
- Scala数据集合操作
- 哈夫曼树及其应用
- 什么是公有IP地址?什么是私有IP地址?及各自范围介绍
- 装箱、拆箱以及Math类
- ANDROID开发之SQLite详解