IDEA的使用(1 springboot从无到hello world)

随着IDEA的出现,原来越多的JAVA程序员在使用IDEA,为了跟上时代的步伐,从鄙视链中向到上一级,学习IDEA的使用

新建springboot项目


然后等待下载


每次下载都很慢,很大概率会下载失败,不知道有没有什么好的建议,已经失败好多次了


浏览器是可以访问 https://start.spring.io/ 的,

失败若干次之后,终于成功了


项目 结构


启动方法

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class DemoApplication {

   public static void main(String[] args) {
      SpringApplication.run(DemoApplication.class, args);
   }
}
新建一个helloworld 

package com.example.demo.web;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by shj on 2018/7/12.
 */

@RestController

public class HelloWorld {

    @RequestMapping("/hello")
    public  String index(){

        return  "hello world";
    }
}

终于见到hello world ,feel so good








遇到的问题

IDEA 没有目录结构


解决方案

file -> 项目结构 ->Modules



选择加号 import module


找到当前项目-->确定


选择maven


选择root directory


之后一直按照默认选项就好




pom.xml中的依赖包没有导入到项目中

 项目配置 facets 重新配置一遍



Whitelabel Error Page

This application has no explicit mapping for /error, so you are seeing this as a fallback.

Thu Jul 12 10:01:30 CST 2018
There was an unexpected error (type=Not Found, status=404).
No message available

目录结构出错


猜你喜欢

转载自blog.csdn.net/aa15237104245/article/details/81002962
今日推荐