springcloud实战一:搭建springboot

声明:博客内容均参考自  Spring Cloud微服务实战_翟永超 ,Spring Cloud与Docker微服务架构实战_周立 

构建springboot项目:

一.通过网址构建:

1.http://start.spring.io/

    

2.各个依赖包


构建好之后,点击genrent project下载即可。

二:本地环境配置调试:

1.目录结构如下:


2.配置信息:

application.yml/application.properties文件  yml配置文件一定要注意格式缩进。

server:
  port: 8888
spring:
  application:
    name: firstObject
 
 

3.pom文件:

 
 
<?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>fristProject</artifactId>
   <version>0.0.1-SNAPSHOT</version>
   <packaging>jar</packaging>

   <name>fristProject</name>
   <description>Demo project for Spring Boot</description>

   <parent>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-parent</artifactId>
      <version>2.0.2.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>
      </dependency>

   </dependencies>

   <build>
      <plugins>
         <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
         </plugin>
      </plugins>
   </build>

   <!--<dependencyManagement>-->
      <!--<dependencies>-->
         <!--<dependency>-->
            <!--<groupId>org.springframework.cloud</groupId>-->
            <!--<artifactId>spring-cloud-dependencies</artifactId>-->
            <!--<version>Dalston.SR4</version>-->
            <!--<type>pom</type>-->
            <!--<scope>import</scope>-->
         <!--</dependency>-->
      <!--</dependencies>-->
   <!--</dependencyManagement>-->


</project>

启动成功:


第一个springboot项目就搭建完成了。

如遇到启动失败的情况,还无明显错误,可重新clean+install,可能是包缺失的原因。

注明:本文只用于自主学习,不涉及商业用途。如有侵权请告知。

        

猜你喜欢

转载自blog.csdn.net/qq_30653841/article/details/80288243