您现在的位置是:首页 > 博文答疑 > IntelliJ IDEA下第一个SPRINTBOOT程序博文答疑
IntelliJ IDEA下第一个SPRINTBOOT程序
Leo2017-05-17【5】
简介IntelliJ IDEA下第一个SPINTBOOT程序
准备工作:
请参考上一篇文章《IntelliJ IDEA下第一个SPARK程序》
设置:
基于之前的设置,配置文件中增加sprintbook相关依赖。
name := "SparkLearning" version := "1.0" scalaVersion := "2.12.2" libraryDependencies ++= Seq( "org.apache.spark" % "spark-core_2.11" % "2.1.1", "org.apache.spark" % "spark-streaming_2.11" % "2.1.1", "org.springframework.boot" % "spring-boot-starter-parent" % "1.5.3.RELEASE", "org.springframework.boot" % "spring-boot-starter-web" % "1.5.3.RELEASE" ) libraryDependencies += "org.springframework" % "spring-core" % "4.3.7.RELEASE"
在main目录下创建java文件夹,创建java类"SampleController"
package com.test;
import org.springframework.boot.*;
import org.springframework.boot.autoconfigure.*;
import org.springframework.stereotype.*;
import org.springframework.web.bind.annotation.*;
@Controller
@EnableAutoConfiguration
/**
* Created by Administrator on 2017/5/16.
*/
public class SampleController {
@RequestMapping("/")
@ResponseBody
String home() {
return "Hello World!";
}
public static void main(String[] args) throws Exception {
SpringApplication.run(SampleController.class, args);
}
}右键-> run,可以看到如下界面

看到server起来后,可以用浏览器打开
