欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

电商项目(四)--后台系统架构初步搭建

程序员文章站 2022-04-14 23:21:44
...

1. 百战商城服务设计

电商项目(四)--后台系统架构初步搭建

2. 创建common_item项目

① 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">
    <parent>
        <artifactId>bz_parent</artifactId>
        <groupId>com.bjsxt</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>common_item</artifactId>

    <dependencies>
        <!--mapper-->
        <dependency>
            <groupId>com.bjsxt</groupId>
            <artifactId>common_mapper</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>

        <!-- utils -->
        <dependency>
            <groupId>com.bjsxt</groupId>
            <artifactId>common_utils</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>

        <!--Spring Boot Web Starter-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <!--Spring Cloud Eureka Client Starter-->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
        </dependency>



    </dependencies>


</project>

② 创建配置文件

spring:
  application:
    name: common-item
  datasource:
    driverClassName: com.mysql.jdbc.Driver
    url: jdbc:mysql://localhost:3306/bz_shop?characterEncoding=UTF-8
    username: root
    password: root
    type: com.alibaba.druid.pool.DruidDataSource

server:
  port: 9010

eureka:
  client:
    serviceUrl:
      defaultZone: http://eureka-server:8761/eureka/

③ 修改mapper的pom文件,添加资源拷贝插件

<build>
        <!-- 资源拷贝插件-->
        <resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.xml</include>
                </includes>
            </resource>

            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>**/*.xml</include>
                </includes>
            </resource>
        </resources>
    </build>

④ 创建启动类

package com.bjsxt.item;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;

/**
 * 通用服务
 */
@SpringBootApplication
@EnableDiscoveryClient
@MapperScan("com.bjsxt.mapper")
public class CommonItemApplication {
    public static void main(String[] args) {
        SpringApplication.run(CommonItemApplication.class,args);.
    }
}

⑤ 修改Host文件添加注册中心域名与IP的映射

电商项目(四)--后台系统架构初步搭建
电商项目(四)--后台系统架构初步搭建

相关标签: 电商