• 项目积累demo-01


    1 搭建Spring-Boot项目

      在这里我使用intellij新建spring boot工程;

        点击next;

     输入Group以及artifact之后。点击next.之后点击web.接着finish就ok了

    测试案列,证明spring boot工程搭建完毕;
    ·1)依赖的pom.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
    
        <groupId>com.gosaint.spring.boot.blog</groupId>
        <artifactId>initiallizr-start</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <packaging>jar</packaging>
    
        <name>initiallizr-start</name>
        <description>Demo project for Spring Boot</description>
    
        <parent>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>1.5.9.RELEASE</version>
            <relativePath/> <!-- lookup parent from repository -->
        </parent>
    
        <properties>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
            <java.version>1.8</java.version>
        </properties>
    
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter</artifactId>
            </dependency>
    
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-test</artifactId>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
                <version>RELEASE</version>
            </dependency>
        </dependencies>
    
        <build>
            <plugins>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                </plugin>
            </plugins>
        </build>
    
    
    </project>

    测试demo(该类是程序自动生成的)

    package com.gosaint.spring.boot.blog.initiallizrstart;
    
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.ResponseBody;
    
    @Controller
    @EnableAutoConfiguration
    @SpringBootApplication
    public class InitiallizrStartApplication {
    
        @RequestMapping("/hello")
        @ResponseBody
        String home() {
            return "Hello World!";
        }
        public static void main(String[] args) {
            SpringApplication.run(InitiallizrStartApplication.class, args);
        }
    }

    启动main()方法;如下所示

    访问localhost:8080/hello:

    好了,就此一个Spring-Boot的web工程已经启动了!

     

     

  • 相关阅读:
    cc.Component
    cc.Node—坐标系统
    cc.Node—事件响应
    cc.Node—Action
    cc.Node—场景树
    console.log格式化及console对象
    网站开发学习Python实现-Django项目部署-介绍(6.2.1)
    个人博客搭建Python实现-尝试-遇到的问题(10.1.1)
    工具-Redis-django存储session(99.6.4)
    工具-Redis-与Python一起使用(99.6.3)
  • 原文地址:https://www.cnblogs.com/gosaint/p/8277756.html
Copyright © 2020-2023  润新知