web项目2-创建一个HelloWorld项目

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/DTJ_74/article/details/88086432

上一篇博客介绍了如何通过Spring 那个网站自动生成配置。

web项目1-创建一个简单的web开发项目


这个博客是重新建项目进行配置一个SpringBoot 的HelloWorld 项目的。

我用的是这个 ide ,很高端的样子,比eclipse 。

按照这个图示直接创建 一个项目。

扫描二维码关注公众号,回复: 5404113 查看本文章

创建完之后是这样子的

接下来配置SpringBoot 依赖相关。

buildscript {
    // ext 用于定义动态属
    ext {
        springBootVersion = '2.1.3.RELEASE'
    }
    // 依赖关系
    dependencies {
        // classpath 声明说明了在执行其余的脚本时,ClassLoader 可以使用这些依赖项
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}


plugins {
    id 'java'
}
group 'com.twc.uu'
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
    mavenCentral()
    //配置多一个阿里仓库。
    maven {
        url 'http://maven.aliyun.com/nexus/content/groups/public/'
    }
}


dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.12'
    compile 'org.springframework.boot:spring-boot-starter-web:2.1.3.RELEASE'
}
package com.twc.uu.helloworld;

import javafx.application.Application;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class UUApp {
    public static void main(String[] args) {
        SpringApplication.run(UUApp.class, args);
    }
}
package com.twc.uu.helloworld.controller;

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

@RestController
public class HelloController {
    @RequestMapping("/hello")
    public String hello() {
        return "Hello World! Welcome ";
    }
}

然后构建项目。。。。

最后helloworld 项目就创建完成了。

下一篇:web项目3-相关技术的介绍

猜你喜欢

转载自blog.csdn.net/DTJ_74/article/details/88086432