• spring boot入门学习---1


    1.maven配置

    <?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.example</groupId>
        <artifactId>myproject</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    
        <!-- Inherit defaults from Spring Boot -->
        <parent>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>1.4.3.RELEASE</version>
        </parent>
    
        <!-- Add typical dependencies for a web application -->
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
            </dependency>
        </dependencies>
        <!-- Package as an executable jar -->
        <build>
            <plugins>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                </plugin>
            </plugins>
        </build>
    </project>

    2.简单运行

    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    @SpringBootApplication
    public class GirlApplication {
        public static void main(String[] args) {
            //启动方式
            SpringApplication.run(GirlApplication.class, args);
        }
    }
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RequestMethod;
    import org.springframework.web.bind.annotation.RestController;
    
    @RestController
    public class HelloController {
        @RequestMapping(value = "/hello", method = RequestMethod.GET)
        public String say() {
            return "Hello Spring Boot!";
        }
    }

    3.配置访问

    配置文件application.properties指定访问端口和路径

    server.port=8081
    server.context-path=/girl

    ******

    3.连接数据库属性文件配置

     

     

  • 相关阅读:
    3里氏代换原则LSP
    2单一职责原则SRP
    1开放封闭原则OCP
    24访问者模式Visitor
    python json模块,处理json文件的读写
    python zip 绑定多个list
    python 字符串重复多次的技巧 *操作符
    python 刷新缓冲区,实时监测
    python os.getcwd 获取工作目录
    python datetime 获取时间
  • 原文地址:https://www.cnblogs.com/kaiwen1/p/8900468.html
Copyright © 2020-2023  润新知