zoukankan      html  css  js  c++  java
  • springboot项目目录结构

    idea新建springboot项目

    按默认下一步至完成,默认目录结构如下

    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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <parent>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>2.1.9.RELEASE</version>
            <relativePath/> <!-- lookup parent from repository -->
        </parent>
        <groupId>com.example</groupId>
        <artifactId>demo</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <name>demo</name>
        <description>Demo project for Spring Boot</description>
    
        <properties>
            <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>
        </dependencies>
    
        <build>
            <plugins>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                </plugin>
            </plugins>
        </build>
    
    </project>

     主类如下

    package com.example.demo;
    
    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);
        }
    
    }

    @SpringBootApplication注解在spring-boot-autoconfigure-2.1.9.RELEASE.jar包下

    SpringApplication类在spring-boot-2.1.9.RELEASE.jar包下 

    主类测试类如下

    package com.example.demo;
    
    import org.junit.Test;
    import org.junit.runner.RunWith;
    import org.springframework.boot.test.context.SpringBootTest;
    import org.springframework.test.context.junit4.SpringRunner;
    
    @RunWith(SpringRunner.class)
    @SpringBootTest
    public class DemoApplicationTests {
    
        @Test
        public void contextLoads() {
        }
    
    }

    @Test和@RunWith注解在junit-4.12.jar包下

    SpringRunner类在spring-test-5.1.10.RELEASE.jar包下

    @SpringBootTest注解在spring-boot-test-2.1.9.RELEASE.jar包下

    application.properties为空

  • 相关阅读:
    Office 365开发环境概览
    Office 365开发概述及生态环境介绍(二)
    介绍Office 365 中文用户社区 4.0
    学习一点Markdown的基本知识
    Office 365开发概述及生态环境介绍(一)
    如何完全卸载OneDrive (Windows 10 64bit)
    国内版Office 365和Azure AAD绑定的问题及解决方案
    Office 365常见问题解答(第一期)
    招聘视音频工程师
    信念、思考、行动-谈谈程序员返回家乡的创业问题
  • 原文地址:https://www.cnblogs.com/yanguobin/p/11625081.html
Copyright © 2011-2022 走看看