• IDEA使用全解


    IDEA使用教程

    创建JavaSE工程及运行

    创建工程

    File---->New---->project

    image-20201126164519739

    java---->next

    image-20201126164538810

    image-20201126164552185

    设置项目名,包名,工程目录

    image-20201126164606353

    项目的目录结构

    image-20201126164621772

    Java文件的创建与编译运行

    回车创建成功

    运行:

    image-20201126164633514

    image-20201126164651075

    image-20201126164730333

    image-20201126164746653

    IDEA的常用配置

    设置面板,设置内容都在这里

    每次设置完右下角先点击Apply,后点击OK,再退出

    image-20201126164800173

    image-20201126164810008

    1.设置字体大小

    打开控制面板

    image-20201126164823599

    设置代码提示不区分大小写

    可帮助开发人员提示代码

    image-20201126164840553

    自动导包import设置

    image-20201126164855201

    设施类注释模板

    image-20201126164904700

    设置内容:

    /**
     *@Description TODO 类的作用
     *@Author ${USER}
     *@Date ${DATE} ${TIME}
     *Version 1.0
     **/

    设置全局编码格式

    image-20201126164917002

    IDEA常用快捷键

    类中输入psvm快速创建main方法

    输入sout创建输出语句System.out.println();

    Ctrl+Alt+T,将选中的代码进行如下操作

    image-20201126164931019

    Alt+Insert,快速进行如下操作:

    image-20201126164945867

    Spring Boot

    一、Spring Boot基础原理

    1. Spring Boot概述

    1.1 什么是Spring Boot

    Spring Boot是Spring项目中的一个子工程,与我们所熟知的Spring-framework同属于Spring的产品。

    一般把Spring Boot成为搭建程序的脚手架或者说便于搭建基于Spring的工程脚手架。最主要的作用就是帮助开发发人员搭建庞大的Spring项目,并且尽可能的减少一切xml配置,做到开箱即用,迅速上手,让开发人员关注业务儿非配置。

    1.2 为什么学习Spring Boot

    java复杂的配置,混乱的依赖管理。简化了基于Spring的应用开发。

    1.3 Spring Boot的特点

    1. 创建独立的Spring应用

    2. 直接嵌入应用服务器,不需要部署war包

    3. 提供固定的启动器以来去简化组件配置

    4. 自动的配置Spring和其他有需要的第三方依赖

    5. 绝对没有代码生成,也无需XML配置

    2. Spring Boot入门

    目标:能够使用Spring Boot搭建项目

    分析

    需求:可以在浏览器中访问Http://localhost:8080/hello输出helloword

    实现步骤:

    1. 创建工程

      image-20201126164334902

      image-20201126164401992

      image-20201126164417527

      image-20201126164433060

    2. 添加依赖(启动器依赖,spring-boot-starter-web)

      pom.xml中可自动添加以下依赖:

      <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-web</artifactId>
      </dependency>

      <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-test</artifactId>
         <scope>test</scope>
         <exclusions>
             <exclusion>
                 <groupId>org.junit.vintage</groupId>
                 <artifactId>junit-vintage-engine</artifactId>
             </exclusion>
         </exclusions>
      </dependency>
    3. 创建启动类

      idea自动创建:

      package com.why.sb_study;

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

      /**
      * Spring boot工程都有一个启动引导类,工程的入口类
      * 并在引导类上添加@SpringBootApplication注解
      */
      @SpringBootApplication
      public class SbStudyApplication {

         public static void main(String[] args) {
             SpringApplication.run(SbStudyApplication.class, args);
        }

      }
    4. 创建处理器Controller

      package com.why.sb_study.controller;

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

      /**
      * @Description TODO 展示hello world
      * @Author why
      * @Date 2020/10/9 18:35
      * Version 1.0
      **/
      @RestController//里面的所有方法返回结果都返回字符类型
      public class HwController {

         @GetMapping("hello")
         public String hello(){
             return "Hello Spring Boot";
        }
      }
    5. 测试

      image-20201126164453422

      小结:

      Spring Boot工程可以通过添加启动器依赖和创建启动引导类实现快速创建web工程。

      Spring Boot默认的访问端口是8080

    6.  

  • 相关阅读:
    Atitit 图像处理30大经典算法attilax总结
    Atitit 图像清晰度 模糊度 检测 识别 评价算法 源码实现attilax总结
    Atitit  rgb yuv  hsv HSL 模式和 HSV(HSB) 图像色彩空间的区别
    Atitit  从 RGB 到 HSL 或 HSV 的转换
    Atitit 图像清晰度 模糊度 检测 识别 评价算法 原理
    Atitit 修改密码的功能流程设计 attilax总结
    atitit 点播系统 概览 v2 qb1.docx
    Atitit dsl exer v3 qb3 新特性
    atitit.TokenService v3 qb1  token服务模块的设计 新特性.docx
    Atitit 异常机制与异常处理的原理与概论
  • 原文地址:https://www.cnblogs.com/whystudyjava/p/14043146.html
Copyright © 2020-2023  润新知