TemplarJQ / migration-system-eureka-server

服务迁移系统的注册中心节点,主要由Eureka的服务端代码组成
0 stars 0 forks source link

[Project] - 项目建立过程 #3

Open TemplarJQ opened 3 years ago

TemplarJQ commented 3 years ago

记录项目的搭建过程,目前这个版本针对的是server的搭建顺序

TemplarJQ commented 3 years ago

1.建立项目

1.1 创建并使用pom

父包

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.3.7.RELEASE</version>
    </parent>

关键依赖

      <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-web</artifactId>
      </dependency>

      <dependency>
          <groupId>org.springframework.cloud</groupId>
          <artifactId>spring-cloud-starter-eureka-server</artifactId>
          <version>1.4.6.RELEASE</version>
      </dependency>

      <!--启动tomcat失败,java9+的JAXB默认不加载-->
      <dependency>
          <groupId>javax.xml.bind</groupId>
          <artifactId>jaxb-api</artifactId>
          <version>2.3.0</version>
      </dependency>
      <dependency>
          <groupId>com.sun.xml.bind</groupId>
          <artifactId>jaxb-impl</artifactId>
          <version>2.3.0</version>
      </dependency>
      <dependency>
          <groupId>org.glassfish.jaxb</groupId>
          <artifactId>jaxb-runtime</artifactId>
          <version>2.3.0</version>
      </dependency>
      <dependency>
          <groupId>javax.activation</groupId>
          <artifactId>activation</artifactId>
          <version>1.1.1</version>
      </dependency>

包管理

<dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>Brixton.SR5</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

1.2完成主类的书写

@EnableEurekaServer
@SpringBootApplication
public class EurekaApplication
{
    public static void main( String[] args )
    {
        SpringApplication.run(EurekaApplication.class, args);
        System.out.println( "Hello World!" );
    }
}

1.3加入application.properties

server.port=3021

#注册中心不用注册自己
eureka.instance.hostname=localhost
eureka.client.register-with-eureka=false
#注册中心的职责为维护实例,不需要去检索服务
eureka.client.fetch-registry=false

eureka.client.service-url.defaultZone=http://${eureka.instance.hostname}:${server.port}/eureka