Spring Boot入门
基础环境 IDEA
Create New Project => Spring Initializr=> Next = >
Web = > Spring Web=>.....
加入以下代码
package com.example.demo; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; @Controller public class HelloController { @RequestMapping("/hello") @ResponseBody public String hello(){ return "Hello World!!"; } }
访问 http://localhost:8080/hello
SpringBoot2.x使用Dev-tool热部署
当修改某些文件内容如配置文件时,我们需要重新启动服务器,比较麻烦,需要一个工具来进行检测是否修改。热加载可以检测到修改的部分,提高工作效率,只要保存后,即可实现热加载。
Q1:Initialization failed for 'https://start.spring.io'
Please check URL, network and proxy settings.
需要设置代理
Q2:Warning:java: 源值1.5已过时, 将在未来所有发行版中删除
Module xxx is imported from Maven.Any changes made in its configuration may be lost after reimpor...
正确修改方式为修改pom.xml
File => Setting => Java Compile=> "Project bytecode version"修改为8
Per-module bytecode version => 1.8
File => Project Structure=> Modules=> Language修改为8
Q3:Error:(3, 32) java: 程序包org.springframework.boot不存在
需要配置maven
参考网址: https://www.cnblogs.com/zmfx/p/8903688.html

浙公网安备 33010602011771号