Browse Source

添加docker容器化部署,配置区分dev和prod环境

zhh 6 years ago
parent
commit
8cb20508e8

+ 8 - 6
README.md

@@ -9,7 +9,7 @@
 Spring Boot | 容器+MVC框架
 Spring Security | 认证和授权框架
 MyBatis | ORM框架  
-MyBatisGenerator | 代码生成  
+MyBatisGenerator | 数据层代码生成  
 PageHelper | MyBatis物理分页插件  
 Swagger-UI | 文档生产工具
 Hibernator-Validator | 验证框架
@@ -17,6 +17,7 @@ Elasticsearch | 搜索引擎
 RabbitMq | 消息队列
 Redis | 分布式缓存
 MongoDb | NoSql数据库
+Docker | 应用容器引擎
 
 ### 前端技术
 
@@ -51,13 +52,14 @@ JTA事务处理 | ✔
 集成单元测试 | ✔
 OSS上传功能 | ✔
 Elasticsearch搜索功能 | ✔
-SpringSecurity权限管理功能 |
 HTTPS支持 | ✔
-日志收集功能 |
-数字型ID生成 |
-定时任务支持 |
+SpringSecurity权限管理功能 |
+ELK日志收集功能 |
+Redis数字型ID生成 |
+SpringTask定时任务支持 |
 RestTemplate服务间调用 |
-docker容器化部署 |
+docker容器化部署 | ✔
+配置区分生产和测试环境 | ✔
 
 ### 后台功能
 

+ 19 - 1
docker-deploy.md → document/docker/docker-deploy.md

@@ -109,4 +109,22 @@ docker pull mongo:3.2
 ###创建实例并运行
 docker run -p 27017:27017 --name mongo -v $PWD/db:/data/db -d mongo:3.2
 ###使用mongo命令进入容器
-docker exec -it mongo mongo
+docker exec -it mongo mongo
+
+##SpringBoot应用部署
+**docker容器间进行连接才能互相访问**
+###部署mall-admin
+docker run -p 8080:8080 --name mall-admin \
+--link mysql:db \
+-d mall/mall-admin:0.0.1-SNAPSHOT
+###部署mall-search
+docker run -p 8081:8081 --name mall-search \
+--link elasticsearch:es \
+--link mysql:db \
+-d mall/mall-search:0.0.1-SNAPSHOT
+###部署mall-port
+docker run -p 8085:8085 --name mall-portal \
+--link mysql:db \
+--link redis:redis \
+--link mongo:mongo \
+-d mall/mall-portal:0.0.1-SNAPSHOT

+ 87 - 0
document/docker/docker.md

@@ -0,0 +1,87 @@
+#Docker笔记
+
+##Docker 镜像常用命令
+###搜索镜像
+docker search java
+###下载镜像
+docker pull java:8
+docker pull macro/eureka-server:0.0.1
+###列出镜像
+docker images
+###删除镜像
+docker rmi java
+docker rmi -f java 
+docker rmi -f $(docker images)
+
+##Docker 容器常用命令
+###新建并启动容器
+docker run -d -p 91:80 nginx
+###列出容器
+docker ps
+###停止容器
+docker stop $ContainerId
+###强制停止容器
+docker kill $ContainerId
+###启动已停止的容器
+docker start $ContainerId
+###进入容器
+docker inspect --format "{{.State.Pid}}" $ContainerId
+nsenter --target "$pid" --mount --uts --ipc --net --pid
+###删除容器
+docker rm $ContainerId
+docker rm -f $(docker ps -a -q)
+
+##Docker Registry
+###Docker Registry 2.0搭建
+docker run -d -p 5000:5000 --restart=always --name registry2 registry:2
+###推送到私有仓库
+docker push localhost:5000/macro/eureka-server:0.0.1
+###修改镜像标签
+docker tag macro/eureka-server:0.0.1 localhost:5000/macro/eureka-server:0.0.1
+
+##使用maven构建Docker镜像
+###构建镜像
+- command:mvn clean package docker:build
+- tip:
+    Linux服务器需要开启远程api:vi /usr/lib/systemd/system/docker.service
+    修改为:ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock   
+###推送镜像到私有仓库
+- command:mvn clean package docker:build -DpushImage
+- tip:
+    pom.xml修改<imageName>192.168.1.71:5000/macro/${project.artifactId}:${project.version}</imageName>
+- tip:
+    docker要支持http:echo '{ "insecure-registries":["192.168.1.71:5000"] }' > /etc/docker/daemon.json 
+###修改Docker镜像存放位置
+1. 查看Docker的存放位置:docker info | grep "Docker Root Dir"(默认为/var/lib/docker)
+2. 关闭Docker服务:systemctl stop docker
+3. 移动目录到目标路径:mv /var/lib/docker /root/data/docker
+4. 建立软连接:ln -s /root/data/docker /var/lib/docker
+
+##Docker compose
+###安装
+1. 下载地址:https://github.com/docker/compose/releases
+2. 安装地址:/usr/local/bin/docker-compose
+3. 设置为可执行:sudo chmod +x /usr/local/bin/docker-compose
+4. 测试是否安装成功:docker-compose --version
+
+###安装命令补全工具
+sudo curl -L https://raw.githubusercontent.com/docker/compose/1.22.0/contrib/completion/bash/docker-compose -o /etc/bash_completion.d/docker-compose
+
+###常用命令
+- 构建、创建、启动相关容器:docker-compose up
+- 列出所有容器:docker-compose ps
+- 删除指定服务的容器:docker-compose rm eureka
+- 对容器进行动态扩容:docker-compose scale eureka=3
+- 停止相关容器:docker-compose stop eureka
+- 启动相关容器:docker-compose start eureka
+
+###编排SpringCloud微服务
+####所使用到的工程
+- eureka-server
+- hello-service
+- feign-consumer
+- api-gateway
+####编排模式
+1. 编排SpringCloud微服务:见eureka-server/docker-res/docker-compose.yml
+2. 简化SpringCloud微服务编排:见eureka-server/docker-res/docker-compose-simple.yml
+3. 编排高可用的注册中心:见eureka-server/docker-res/docker-compose-eureka.yml

+ 4 - 0
document/docker/host.txt

@@ -0,0 +1,4 @@
+192.168.1.71 db
+192.168.1.71 es
+192.168.1.71 redis
+192.168.1.71 mongo

+ 46 - 7
document/sql/mall.sql

@@ -10,7 +10,7 @@ Target Server Type    : MYSQL
 Target Server Version : 50719
 File Encoding         : 65001
 
-Date: 2018-06-21 10:11:27
+Date: 2018-08-20 13:53:09
 */
 
 SET FOREIGN_KEY_CHECKS=0;
@@ -138,7 +138,7 @@ CREATE TABLE `cms_subject` (
   `content` text,
   `forward_count` int(11) DEFAULT NULL COMMENT '转发数',
   PRIMARY KEY (`id`)
-) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8 COMMENT='专题表';
+) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8 COMMENT='专题表';
 
 -- ----------------------------
 -- Records of cms_subject
@@ -278,6 +278,41 @@ CREATE TABLE `cms_topic_comment` (
 -- Records of cms_topic_comment
 -- ----------------------------
 
+-- ----------------------------
+-- Table structure for oms_cart_item
+-- ----------------------------
+DROP TABLE IF EXISTS `oms_cart_item`;
+CREATE TABLE `oms_cart_item` (
+  `id` bigint(20) NOT NULL AUTO_INCREMENT,
+  `product_id` bigint(20) DEFAULT NULL,
+  `product_sku_id` bigint(20) DEFAULT NULL,
+  `member_id` bigint(20) DEFAULT NULL,
+  `quantity` int(11) DEFAULT NULL COMMENT '购买数量',
+  `price` decimal(10,2) DEFAULT NULL COMMENT '添加到购物车的价格',
+  `sp1` varchar(200) DEFAULT NULL COMMENT '销售属性1',
+  `sp2` varchar(200) DEFAULT NULL COMMENT '销售属性2',
+  `sp3` varchar(200) DEFAULT NULL COMMENT '销售属性3',
+  `product_pic` varchar(1000) DEFAULT NULL COMMENT '商品主图',
+  `product_name` varchar(500) DEFAULT NULL COMMENT '商品名称',
+  `product_sub_title` varchar(500) DEFAULT NULL COMMENT '商品副标题(卖点)',
+  `product_sku_code` varchar(200) DEFAULT NULL COMMENT '商品sku条码',
+  `member_nickname` varchar(500) DEFAULT NULL COMMENT '会员昵称',
+  `create_date` datetime DEFAULT NULL COMMENT '创建时间',
+  `modify_date` datetime DEFAULT NULL COMMENT '修改时间',
+  `delete_status` int(1) DEFAULT '0' COMMENT '是否删除',
+  PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8 COMMENT='购物车表';
+
+-- ----------------------------
+-- Records of oms_cart_item
+-- ----------------------------
+INSERT INTO `oms_cart_item` VALUES ('3', '26', null, '1', '4', '3788.00', null, null, null, null, '华为 HUAWEI P20', 'AI智慧全面屏 6GB +64GB 亮黑色 全网通版 移动联通电信4G手机 双卡双待手机 双卡双待', null, 'windir', '2018-08-02 10:23:09', '2018-08-02 10:23:09', '1');
+INSERT INTO `oms_cart_item` VALUES ('4', '26', null, '1', '2', '3788.00', '金色', '16G', null, null, '华为 HUAWEI P20', 'AI智慧全面屏 6GB +64GB 亮黑色 全网通版 移动联通电信4G手机 双卡双待手机 双卡双待', null, 'windir', '2018-08-02 10:23:09', '2018-08-02 10:23:09', '1');
+INSERT INTO `oms_cart_item` VALUES ('5', '27', null, '1', '4', '2699.00', null, null, null, null, '小米8 全面屏游戏智能手机 6GB+64GB 黑色 全网通4G 双卡双待', '骁龙845处理器,红外人脸解锁,AI变焦双摄,AI语音助手小米6X低至1299,点击抢购', null, 'windir', '2018-08-02 10:23:09', '2018-08-02 10:23:09', '0');
+INSERT INTO `oms_cart_item` VALUES ('6', '26', '86', '1', '2', '3788.00', '金色', '16G', null, null, '华为 HUAWEI P20', 'AI智慧全面屏 6GB +64GB 亮黑色 全网通版 移动联通电信4G手机 双卡双待手机 双卡双待', '201806070026001', 'windir', '2018-08-02 10:23:09', '2018-08-02 10:23:09', '1');
+INSERT INTO `oms_cart_item` VALUES ('7', '26', '89', '1', '3', '3788.00', '银色', '32G', null, null, '华为 HUAWEI P20', 'AI智慧全面屏 6GB +64GB 亮黑色 全网通版 移动联通电信4G手机 双卡双待手机 双卡双待', '201806070026004', 'windir', '2018-08-02 10:23:09', '2018-08-02 10:23:09', '1');
+INSERT INTO `oms_cart_item` VALUES ('8', '26', '88', '1', '4', '3788.00', '银色', '16G', null, null, '华为 HUAWEI P20', 'AI智慧全面屏 6GB +64GB 亮黑色 全网通版 移动联通电信4G手机 双卡双待手机 双卡双待', '201806070026003', 'windir', '2018-08-02 10:23:09', '2018-08-02 10:23:09', '0');
+
 -- ----------------------------
 -- Table structure for oms_company_address
 -- ----------------------------
@@ -608,7 +643,7 @@ CREATE TABLE `pms_member_price` (
   `member_price` decimal(10,2) DEFAULT NULL COMMENT '会员价格',
   `member_level_name` varchar(100) DEFAULT NULL,
   PRIMARY KEY (`id`)
-) ENGINE=InnoDB AUTO_INCREMENT=181 DEFAULT CHARSET=utf8 COMMENT='商品会员价格表';
+) ENGINE=InnoDB AUTO_INCREMENT=186 DEFAULT CHARSET=utf8 COMMENT='商品会员价格表';
 
 -- ----------------------------
 -- Records of pms_member_price
@@ -816,7 +851,7 @@ CREATE TABLE `pms_product_attribute_category` (
   `attribute_count` int(11) DEFAULT '0' COMMENT '属性数量',
   `param_count` int(11) DEFAULT '0' COMMENT '参数数量',
   PRIMARY KEY (`id`)
-) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8 COMMENT='产品属性分类表';
+) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8 COMMENT='产品属性分类表';
 
 -- ----------------------------
 -- Records of pms_product_attribute_category
@@ -837,7 +872,7 @@ CREATE TABLE `pms_product_attribute_value` (
   `id` bigint(20) NOT NULL AUTO_INCREMENT,
   `product_id` bigint(20) DEFAULT NULL,
   `product_attribute_id` bigint(20) DEFAULT NULL,
-  `value` varchar(64) DEFAULT NULL COMMENT '存储的值',
+  `value` varchar(64) DEFAULT NULL COMMENT '手动添加规格或参数的值,参数单值,规格有多个时以逗号隔开',
   PRIMARY KEY (`id`)
 ) ENGINE=InnoDB AUTO_INCREMENT=203 DEFAULT CHARSET=utf8 COMMENT='存储产品参数信息的表';
 
@@ -1489,12 +1524,16 @@ CREATE TABLE `ums_member` (
   `growth` int(11) DEFAULT NULL COMMENT '成长值',
   `luckey_count` int(11) DEFAULT NULL COMMENT '剩余抽奖次数',
   `history_integration` int(11) DEFAULT NULL COMMENT '历史积分数量',
-  PRIMARY KEY (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='会员表';
+  PRIMARY KEY (`id`),
+  UNIQUE KEY `idx_username` (`username`),
+  UNIQUE KEY `idx_phone` (`phone`)
+) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 COMMENT='会员表';
 
 -- ----------------------------
 -- Records of ums_member
 -- ----------------------------
+INSERT INTO `ums_member` VALUES ('1', '4', 'test', '202cb962ac59075b964b07152d234b70', 'windir', '18061581849', '1', '2018-08-02 10:35:44', null, '1', '2009-06-01', '上海', '学生', 'test', null, null, null, null, null);
+INSERT INTO `ums_member` VALUES ('3', '4', 'test1', '698d51a19d8a121ce581499d7b701668', null, '18061581848', '1', '2018-08-03 16:46:38', null, null, null, null, null, null, null, null, null, null, null);
 
 -- ----------------------------
 -- Table structure for ums_member_level

+ 34 - 2
mall-admin/pom.xml

@@ -1,10 +1,14 @@
 <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/maven-v4_0_0.xsd">
     <modelVersion>4.0.0</modelVersion>
+
+    <groupId>com.macro.mall</groupId>
     <artifactId>mall-admin</artifactId>
-    <packaging>war</packaging>
+    <version>0.0.1-SNAPSHOT</version>
+    <packaging>jar</packaging>
+
     <name>mall-admin</name>
-    <url>http://maven.apache.org</url>
+    <description>mall-admin project for mall</description>
 
     <parent>
         <groupId>org.springframework.boot</groupId>
@@ -17,6 +21,7 @@
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
         <java.version>1.8</java.version>
+        <skipTests>true</skipTests>
     </properties>
 
     <dependencies>
@@ -87,6 +92,33 @@
                 <groupId>org.springframework.boot</groupId>
                 <artifactId>spring-boot-maven-plugin</artifactId>
             </plugin>
+            <plugin>
+                <groupId>com.spotify</groupId>
+                <artifactId>docker-maven-plugin</artifactId>
+                <version>1.1.0</version>
+                <executions>
+                    <execution>
+                        <id>build-image</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>build</goal>
+                        </goals>
+                    </execution>
+                </executions>
+                <configuration>
+                    <imageName>mall/${project.artifactId}:${project.version}</imageName>
+                    <dockerHost>http://192.168.1.71:2375</dockerHost>
+                    <baseImage>java:8</baseImage>
+                    <entryPoint>["java", "-jar", "-Dspring.profiles.active=prod","/${project.build.finalName}.jar"]</entryPoint>
+                    <resources>
+                        <resource>
+                            <targetPath>/</targetPath>
+                            <directory>${project.build.directory}</directory>
+                            <include>${project.build.finalName}.jar</include>
+                        </resource>
+                    </resources>
+                </configuration>
+            </plugin>
         </plugins>
     </build>
 </project>

+ 5 - 0
mall-admin/src/main/resources/application-dev.properties

@@ -0,0 +1,5 @@
+#===datasource start===
+spring.datasource.url=jdbc:mysql://localhost:3306/mall
+spring.datasource.username=root
+spring.datasource.password=root
+#===datasource end===

+ 5 - 0
mall-admin/src/main/resources/application-prod.properties

@@ -0,0 +1,5 @@
+#===datasource start===
+spring.datasource.url=jdbc:mysql://db:3306/mall
+spring.datasource.username=root
+spring.datasource.password=root
+#===datasource end===

+ 2 - 5
mall-admin/src/main/resources/application.properties

@@ -1,8 +1,5 @@
-#===datasource start===
-spring.datasource.url=jdbc:mysql://localhost:3306/mall
-spring.datasource.username=root
-spring.datasource.password=root
-#===datasource end===
+#ĬÈÏΪ¿ª·¢»·¾³
+spring.profiles.active=dev
 
 #===mybatis start===
 mybatis.mapper-locations=classpath:dao/*.xml,classpath*:com/**/mapper/*.xml

+ 7 - 5
mall-mbg/pom.xml

@@ -2,14 +2,16 @@
 <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>mall</artifactId>
-        <groupId>com.macro</groupId>
-        <version>1.0-SNAPSHOT</version>
-    </parent>
     <modelVersion>4.0.0</modelVersion>
 
+    <groupId>com.macro.mall</groupId>
     <artifactId>mall-mbg</artifactId>
+    <version>1.0-SNAPSHOT</version>
+    <packaging>jar</packaging>
+
+    <name>mall-mbg</name>
+    <description>mall-mbg project for mall</description>
+
     <dependencies>
         <!-- MyBatis 生成器 -->
         <dependency>

+ 28 - 0
mall-portal/pom.xml

@@ -22,6 +22,7 @@
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
         <java.version>1.8</java.version>
+        <skipTests>true</skipTests>
     </properties>
 
     <dependencies>
@@ -82,6 +83,33 @@
                 <groupId>org.springframework.boot</groupId>
                 <artifactId>spring-boot-maven-plugin</artifactId>
             </plugin>
+            <plugin>
+                <groupId>com.spotify</groupId>
+                <artifactId>docker-maven-plugin</artifactId>
+                <version>1.1.0</version>
+                <executions>
+                    <execution>
+                        <id>build-image</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>build</goal>
+                        </goals>
+                    </execution>
+                </executions>
+                <configuration>
+                    <imageName>mall/${project.artifactId}:${project.version}</imageName>
+                    <dockerHost>http://192.168.1.71:2375</dockerHost>
+                    <baseImage>java:8</baseImage>
+                    <entryPoint>["java", "-jar","-Dspring.profiles.active=prod","/${project.build.finalName}.jar"]</entryPoint>
+                    <resources>
+                        <resource>
+                            <targetPath>/</targetPath>
+                            <directory>${project.build.directory}</directory>
+                            <include>${project.build.finalName}.jar</include>
+                        </resource>
+                    </resources>
+                </configuration>
+            </plugin>
         </plugins>
     </build>
 

+ 0 - 20
mall-portal/src/main/java/com/macro/mall/portal/MallPortalApplication.java

@@ -1,35 +1,15 @@
 package com.macro.mall.portal;
 
-import org.apache.catalina.connector.Connector;
 import org.mybatis.spring.annotation.MapperScan;
-import org.springframework.beans.factory.annotation.Value;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
-import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
-import org.springframework.context.annotation.Bean;
 
 @SpringBootApplication
 @MapperScan({"com.macro.mall.mapper","com.macro.mall.portal.dao"})
 public class MallPortalApplication {
-    @Value("${http.port}")
-    private Integer port;
 
     public static void main(String[] args) {
         SpringApplication.run(MallPortalApplication.class, args);
     }
 
-    @Bean
-    public EmbeddedServletContainerFactory servletContainer() {
-        TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory();
-        tomcat.addAdditionalTomcatConnectors(createStandardConnector()); // 添加http
-        return tomcat;
-    }
-
-    //配置http
-    private Connector createStandardConnector() {
-        Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
-        connector.setPort(port);
-        return connector;
-    }
 }

+ 2 - 1
mall-portal/src/main/java/com/macro/mall/portal/config/TomcatConfig.java

@@ -6,16 +6,17 @@ import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory
 import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Profile;
 
 /**
  * tomcat相关配置
  * Created by macro on 2018/8/7.
  */
+@Profile("dev")
 @Configuration
 public class TomcatConfig {
     @Value("${http.port}")
     private Integer port;
-
     @Bean
     public EmbeddedServletContainerFactory servletContainer() {
         TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory();

+ 48 - 0
mall-portal/src/main/resources/application-dev.properties

@@ -0,0 +1,48 @@
+#===https start===
+#开发环境会开启https
+server.port=8443
+server.ssl.key-store=keystore.p12
+server.ssl.key-alias=tomcat
+server.ssl.key-store-password=123456
+server.ssl.key-store-type=PKCS12
+#===https end===
+
+#===logging start===
+logging.level.org.springframework.data.mongodb.core=debug
+logging.level.com.macro.mall.mapper=debug
+logging.level.com.macro.mall.portal.dao=debug
+#===logging end===
+
+#===datasource start===
+spring.datasource.url=jdbc:mysql://localhost:3306/mall
+spring.datasource.username=root
+spring.datasource.password=root
+#===datasource end===
+
+#===mongodb start===
+spring.data.mongodb.host=localhost
+spring.data.mongodb.port=27017
+spring.data.mongodb.database=mall-port
+#===mongodb end===
+
+#===redis start===
+# Redis数据库索引(默认为0)
+spring.redis.database=0
+# Redis服务器地址
+spring.redis.host=localhost
+# Redis服务器连接端口
+spring.redis.port=6379
+# Redis服务器连接密码(默认为空)
+spring.redis.password=
+# 连接池最大连接数(使用负值表示没有限制)
+spring.redis.pool.max-active=8
+# 连接池最大阻塞等待时间(使用负值表示没有限制)
+spring.redis.pool.max-wait=-1
+# 连接池中的最大空闲连接
+spring.redis.pool.max-idle=8
+# 连接池中的最小空闲连接
+spring.redis.pool.min-idle=0
+# 连接超时时间(毫秒)
+spring.redis.timeout=0
+#===redis end===
+

+ 37 - 0
mall-portal/src/main/resources/application-prod.properties

@@ -0,0 +1,37 @@
+#===server start===
+server.port=8085
+#===server end===
+
+#===datasource start===
+spring.datasource.url=jdbc:mysql://db:3306/mall
+spring.datasource.username=root
+spring.datasource.password=root
+#===datasource end===
+
+#===mongodb start===
+spring.data.mongodb.host=mongo
+spring.data.mongodb.port=27017
+spring.data.mongodb.database=mall-port
+#===mongodb end===
+
+#===redis start===
+# Redis数据库索引(默认为0)
+spring.redis.database=0
+# Redis服务器地址
+spring.redis.host=redis
+# Redis服务器连接端口
+spring.redis.port=6379
+# Redis服务器连接密码(默认为空)
+spring.redis.password=
+# 连接池最大连接数(使用负值表示没有限制)
+spring.redis.pool.max-active=8
+# 连接池最大阻塞等待时间(使用负值表示没有限制)
+spring.redis.pool.max-wait=-1
+# 连接池中的最大空闲连接
+spring.redis.pool.max-idle=8
+# 连接池中的最小空闲连接
+spring.redis.pool.min-idle=0
+# 连接超时时间(毫秒)
+spring.redis.timeout=0
+#===redis end===
+

+ 3 - 46
mall-portal/src/main/resources/application.properties

@@ -1,57 +1,14 @@
+#默认为开发环境
+spring.profiles.active=dev
+
 #===server start===
 http.port=8085
-server.port=8443
-server.ssl.key-store=keystore.p12
-server.ssl.key-alias=tomcat
-server.ssl.key-store-password=123456
-server.ssl.key-store-type=PKCS12
 #===server end===
 
-#===logging start===
-logging.level.org.springframework.data.mongodb.core=debug
-logging.level.com.macro.mall.mapper=debug
-logging.level.com.macro.mall.portal.dao=debug
-#===logging end===
-
-#===datasource start===
-spring.datasource.url=jdbc:mysql://localhost:3306/mall
-spring.datasource.username=root
-spring.datasource.password=root
-#===datasource end===
-
 #===mybatis start===
 mybatis.mapper-locations=classpath:dao/*.xml,classpath*:com/**/mapper/*.xml
 #===mybatis end===
 
-#===mongodb start===
-spring.data.mongodb.host=localhost
-#spring.data.mongodb.host=192.168.1.66
-spring.data.mongodb.port=27017
-spring.data.mongodb.database=mall-port
-#===mongodb end===
-
-#===redis start===
-# Redis数据库索引(默认为0)
-spring.redis.database=0
-# Redis服务器地址
-spring.redis.host=localhost
-#spring.redis.host=192.168.1.66
-# Redis服务器连接端口
-spring.redis.port=6379
-# Redis服务器连接密码(默认为空)
-spring.redis.password=
-# 连接池最大连接数(使用负值表示没有限制)
-spring.redis.pool.max-active=8
-# 连接池最大阻塞等待时间(使用负值表示没有限制)
-spring.redis.pool.max-wait=-1
-# 连接池中的最大空闲连接
-spring.redis.pool.max-idle=8
-# 连接池中的最小空闲连接
-spring.redis.pool.min-idle=0
-# 连接超时时间(毫秒)
-spring.redis.timeout=0
-#===redis end===
-
 #===redis custom key start===
 redis.key.prefix.authCode=portal:authCode:
 authCode.expire.seconds=90

+ 30 - 2
mall-search/pom.xml

@@ -3,13 +3,13 @@
          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.macro</groupId>
+    <groupId>com.macro.mall</groupId>
     <artifactId>mall-search</artifactId>
     <version>0.0.1-SNAPSHOT</version>
     <packaging>jar</packaging>
 
     <name>mall-search</name>
-    <description>Demo project for Spring Boot</description>
+    <description>mall-search project for mall</description>
 
     <parent>
         <groupId>org.springframework.boot</groupId>
@@ -22,6 +22,7 @@
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
         <java.version>1.8</java.version>
+        <skipTests>true</skipTests>
     </properties>
 
     <dependencies>
@@ -68,6 +69,33 @@
                 <groupId>org.springframework.boot</groupId>
                 <artifactId>spring-boot-maven-plugin</artifactId>
             </plugin>
+            <plugin>
+                <groupId>com.spotify</groupId>
+                <artifactId>docker-maven-plugin</artifactId>
+                <version>1.1.0</version>
+                <executions>
+                    <execution>
+                        <id>build-image</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>build</goal>
+                        </goals>
+                    </execution>
+                </executions>
+                <configuration>
+                    <imageName>mall/${project.artifactId}:${project.version}</imageName>
+                    <dockerHost>http://192.168.1.71:2375</dockerHost>
+                    <baseImage>java:8</baseImage>
+                    <entryPoint>["java", "-jar", "-Dspring.profiles.active=prod","/${project.build.finalName}.jar"]</entryPoint>
+                    <resources>
+                        <resource>
+                            <targetPath>/</targetPath>
+                            <directory>${project.build.directory}</directory>
+                            <include>${project.build.finalName}.jar</include>
+                        </resource>
+                    </resources>
+                </configuration>
+            </plugin>
         </plugins>
     </build>
 

+ 10 - 0
mall-search/src/main/resources/application-dev.properties

@@ -0,0 +1,10 @@
+#===datasource start===
+spring.datasource.url=jdbc:mysql://localhost:3306/mall
+spring.datasource.username=root
+spring.datasource.password=root
+#===datasource end===
+
+#===es start===
+spring.data.elasticsearch.repositories.enabled = true
+spring.data.elasticsearch.cluster-nodes = 127.0.0.1:9300
+#===es end===

+ 10 - 0
mall-search/src/main/resources/application-prod.properties

@@ -0,0 +1,10 @@
+#===datasource start===
+spring.datasource.url=jdbc:mysql://db:3306/mall
+spring.datasource.username=root
+spring.datasource.password=root
+#===datasource end===
+
+#===es start===
+spring.data.elasticsearch.repositories.enabled = true
+spring.data.elasticsearch.cluster-nodes = es:9300
+#===es end===

+ 4 - 13
mall-search/src/main/resources/application.properties

@@ -1,21 +1,12 @@
+#ĬÈÏΪ¿ª·¢»·¾³
+spring.profiles.active=dev
+
 #===server start===
 server.port=8081
 #===server end===
 
 logging.level.root=info
 
-#===datasource start===
-spring.datasource.url=jdbc:mysql://localhost:3306/mall
-spring.datasource.username=root
-spring.datasource.password=root
-#===datasource end===
-
 #===mybatis start===
 mybatis.mapper-locations=classpath:dao/*.xml,classpath*:com/**/mapper/*.xml
-#===mybatis end===
-
-#===es start===
-spring.data.elasticsearch.repositories.enabled = true
-spring.data.elasticsearch.cluster-nodes = 127.0.0.1:9300
-#spring.data.elasticsearch.cluster-nodes = 192.168.1.66:9300
-#===es end===
+#===mybatis end===

+ 1 - 1
mall-search/src/main/resources/dao/EsProductDao.xml

@@ -28,7 +28,7 @@
             p.recommand_status recommandStatus,
             p.stock stock,
             p.promotion_type promotionType,
-            P.keywords keywords,
+            p.keywords keywords,
             p.sort sort,
             pav.id attr_id,
             pav.value attr_value,

+ 7 - 3
pom.xml

@@ -3,13 +3,17 @@
          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.macro</groupId>
+
+    <groupId>com.macro.mall</groupId>
     <artifactId>mall</artifactId>
-    <packaging>pom</packaging>
     <version>1.0-SNAPSHOT</version>
+    <packaging>pom</packaging>
+
     <modules>
-        <module>mall-admin</module>
         <module>mall-mbg</module>
+        <module>mall-admin</module>
+        <module>mall-search</module>
+        <module>mall-portal</module>
     </modules>
 
 </project>