zoukankan      html  css  js  c++  java
  • 微服务 第一章:Idea快速创建SpringBoot项目

    点击新建项目:

    点击next:

    一直next ,直到创建成功。

    创建完成后的项目结构如下:

    添加maven:

      <parent>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>1.5.2.RELEASE</version>
            <relativePath/> <!-- lookup parent from repository -->
        </parent>
    
        <dependencies>
            <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>
            </dependency>
        </dependencies>
    
        <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    

      

    新建个类:

    LessonOneApplication
    @SpringBootApplication
    public class LessonOneApplication {
    	public static void main(String[] args) {
    		SpringApplication.run(LessonOneApplication.class, args);
    	}
    }
    @RestController
    @RequestMapping
    public class HelloWordController {
        @RequestMapping(value = "/index",method = RequestMethod.GET)
        public String index(){
            return "HelloWord";
        }
    }
    

      

    运行 LessonOneApplication类的主函数方法:

    在浏览器上测试:

    项目创建成功。

    解析

    需要引入的jar包介绍:

    spring-boot-starter:核心模块,包括自动配置支持、日志和YAML
    spring-boot-starter-test:测试模块,包括JUnit、Hamcrest、Mockito
    引入Web模块,需添加spring-boot-starter-web模块

     

  • 相关阅读:
    2018 校招在线编程 20题-01
    ubuntu 配置muduo库
    plsql远程访问配置
    web开发转发和重定向大比拼
    Eclipse中svn同步忽略设置
    静态方法、实例方法和域
    接口中的域
    屏蔽所有异常的方法
    使用axis2时在temp文件产生大量缓存
    spring boot redis分布式锁 (转)
  • 原文地址:https://www.cnblogs.com/yaohuiqin/p/9360005.html
Copyright © 2011-2022 走看看