# youxuan-parent **Repository Path**: lyDevelop/youxuan-parent ## Basic Information - **Project Name**: youxuan-parent - **Description**: 社区团购平台管理、小程序服务端 - **Primary Language**: Java - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 6 - **Forks**: 4 - **Created**: 2023-09-20 - **Last Updated**: 2025-08-22 ## Categories & Tags **Categories**: Uncategorized **Tags**: SpringCloud, MyBatis, Java, ElasticSearch, Redis ## README # 1.项目介绍 社区团购是真实居住社区内居民团体的一种互联网线上线下购物消费行为,是依托真实社区的一种区域化、小众化、本地化、网络化的团购形式。简而言之,它是依托社区和团长社交关系实现生鲜商品流通的新零售模式。 # 2.业务流程 从具体模式看,主要围绕平台、团长、用户三个角色展开: 1. 团长(如社区宝妈、便利店老板等)创建一个群,提前发布优惠商品的链接供用户购买,团长从中抽取佣金; 2. 用户提前一天下单; 3. 平台在收集好订单之后,调动供应链,从仓库发货到自提点(团长家或者便利店); 4. 用户前往自提点提货 # 3.功能架构 **功能架构分为三层** 1. 前台会员应用层 2. 前台团长应用层 3. 基础模块支撑层 # 4.技术架构 # 5.核心技术 - SpringBoot:简化新Spring应用的初始搭建以及开发过程 - SpringCloud:基于Spring Boot实现的云原生应用开发工具,SpringCloud使用的技术:(Spring Cloud Gateway、Spring Cloud OpenFeign、Spring Cloud Alibaba Nacos等) - MyBatis-Plus:持久层框架 - Redis:缓存数据库 - Redisson:基于redis的Java驻内存数据网格,实现分布式锁 - RabbitMQ:消息中间件 - ElasticSearch +Kibana: 全文检索服务器 +可视化数据监控 - ThreadPoolExecutor:线程池来实现异步操作,提高效率 - OSS:(MinIo)文件存储服务 - Knife4j(Swagger):Api接口文档工具 - Nginx:负载均衡 - MySQL:关系型数据库 - 微信支付 - 微信小程序(uni-app) # 6.项目模块 ``` youxuan-parent ├── common # 公共类父模块 ├── common-util # 核心工具类 ├── rabbit_util # 消息队列工具类 ├── service-util # 服务工具类 ├── model # 实体类模块 ├── service # 微服务模块 ├── service-client # 远程调用模块 ├── service_gateway # 网关模块 ├── sql # 数据库脚本 ``` # 7. 项目启动配置 ## 7.1 数据库(MySQL 8.0.30) 项目启动之前,首先需要先创建当前项目中需要的数据库及表和数据。 当前项目使用 MySQL 数据库。建议使用 Docker 启动一个本地的数据库环境,因为简单,避免了一些繁琐的配置。 - docker 拉取 Mysql 镜像。 ```sh docker pull mysql:8.0.30 ``` - 启动 Mysql 容器。 ```sh docker run --name mysql \ -e MYSQL_ROOT_PASSWORD=root \ -p 3306:3306 \ -v /my/own/datadir:/var/lib/mysql \ -d mysql:8.0.30 \ --default-authentication-plugin=mysql_native_password ``` - 本地连接数据库进行验证,用户名以及密码都是 root。 ### 7.1.1 数据库的创建以及数据导入。 1. 首先找到当前工程目录下的 `sql` 文件夹。 2. sql 文件的名称就是数据库的名字。使用sql执行或是直接使用可视化工具创建都可以。 ```sql CREATE DATABASE database_name; ``` 3. 数据库创建完成之后使用命令行将执行这些sql,将表和数据导入到对应的数据库中。 ```sh mysql -u username -p database_name < /path/to/yourfile.sql ``` 4. 上述操作完成之后就可以看到数据库中的表以及数据都存在了。 ### 7.1.2 修改项目中的 `application-dev.yml` 找到项目中的 `application-dev.yml` 文件,将数据库连接相关的部分,修改成自己本地的数据库信息。 ## 7.2 Redis 推荐使用 Docker 部署。流程与上述 Mysql 相同。 ### 7.2.1 Redis 服务部署 - 拉取镜像 ```sh docker pull redis ``` - 启动容器 ```sh docker run --name redis_server -d -p 6379:6379 redis:latest ``` - 验证容器是否启动成功 ```sh docker ps ``` - 启动成功后会如下面显示 ``` liuyang@MacBook-Pro ~ % docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 291c10979b8b redis:latest "docker-entrypoint.s…" 5 days ago Up 4 minutes 0.0.0.0:6379->6379/tcp redis-server liuyang@MacBook-Pro ~ % ``` ### 7.2.2 配置文件修改 如果设置了密码之类的需要将项目中配置文件中有关于 Redis 配置相关的部分修改成自己的。 如果只是如我这般简单的启动了 redis 那么不需要做任何设置。 ## 7.3 Nacos ### 7.3.1 Nacos 服务部署 - 拉取镜像 ```sh docker pull nacos/nacos-server:latest ``` - 启动容器 ```sh docker run -d --name nacos -e MODE=standalone -p 8848:8848 nacos/nacos-server ``` - 验证启动 ```sh docker ps ``` - 可以直接访问 `http://localhost:8848/nacos` 来看 Nacos 服务是否启动。 如果启动成功是可以看到 Nacos 管理平台的。 ## 7.4 RabbitMQ - 拉取镜像 ```sh docker pull rabbitmq ``` - 运行容器 ```sh docker run -d --name rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq ``` - RabbitMQ 的默认镜像是不支持 webUI 界面的,需要手动开启 - 进入容器 ```sh docker exec -it rabbitmq bash ``` - 执行如下命令来启用管理插件 ```sh rabbitmq-plugins enable rabbitmq_management ``` - 重启容器 ```sh docker restart rabbitmq ``` - 访问 `http://localhost:15672` 可以进入 RabbitMQ 的 Web 管理界面,用户名密码都是 guest ## 7.5 ElasticSearch - 拉取镜像 ```sh docker pull elasticsearch:8.16.1 ``` - 启动容器 ```sh docker run -d --name elasticsearch \ -p 9200:9200 -p 9300:9300 \ --privileged \ -e "discovery.type=single-node" \ -e ES_JAVA_OPTS="-Xms256m -Xmx512m" \ elasticsearch:8.16.1 ``` ## 7.6 项目启动测试 配置好上述的服务之后,可以验证一下项目是否可以正常启动。 此处以 `service-user` 微服务模块做示范。 找到 `ServiceUserApplication.java` 文件,右键执行。 出现下面的信息说明项目启动没有问题: ``` 2024-12-14 12:28:06.410 INFO 13142 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v2.3.6.RELEASE) 2024-12-14 12:28:07.029 INFO 13142 --- [ restartedMain] com.youxuan.ssyx.ServiceUserApplication : The following profiles are active: dev 2024-12-14 12:28:08.524 INFO 13142 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode! 2024-12-14 12:28:08.526 INFO 13142 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data Redis repositories in DEFAULT mode. 2024-12-14 12:28:08.585 INFO 13142 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 45ms. Found 0 Redis repository interfaces. 2024-12-14 12:28:09.056 INFO 13142 --- [ restartedMain] o.s.cloud.context.scope.GenericScope : BeanFactory id=5d690404-5203-3006-b9ac-99955a54270a 2024-12-14 12:28:09.911 INFO 13142 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'spring.cloud.sentinel-com.alibaba.cloud.sentinel.SentinelProperties' of type [com.alibaba.cloud.sentinel.SentinelProperties] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2024-12-14 12:28:09.920 INFO 13142 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'com.alibaba.cloud.sentinel.custom.SentinelAutoConfiguration' of type [com.alibaba.cloud.sentinel.custom.SentinelAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2024-12-14 12:28:10.796 INFO 13142 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8206 (http) 2024-12-14 12:28:10.814 INFO 13142 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat] 2024-12-14 12:28:10.814 INFO 13142 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.39] 2024-12-14 12:28:10.996 INFO 13142 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 2024-12-14 12:28:10.997 INFO 13142 --- [ restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 3911 ms Logging initialized using 'class org.apache.ibatis.logging.stdout.StdOutImpl' adapter. Registered plugin: 'com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor@6486e0bd' Property 'mapperLocations' was not specified. _ _ |_ _ _|_. ___ _ | _ | | |\/|_)(_| | |_\ |_)||_|_\ / | 3.4.1 2024-12-14 12:28:13.746 INFO 13142 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729 2024-12-14 12:28:14.097 INFO 13142 --- [ restartedMain] org.redisson.Version : Redisson 3.11.2 2024-12-14 12:28:14.703 INFO 13142 --- [isson-netty-4-1] o.r.c.pool.MasterPubSubConnectionPool : 1 connections initialized for localhost/127.0.0.1:6379 2024-12-14 12:28:14.708 INFO 13142 --- [isson-netty-4-3] o.r.c.pool.MasterConnectionPool : 10 connections initialized for localhost/127.0.0.1:6379 2024-12-14 12:28:14.956 INFO 13142 --- [ restartedMain] pertySourcedRequestMappingHandlerMapping : Mapped URL path [/v2/api-docs] onto method [springfox.documentation.swagger2.web.Swagger2ControllerWebMvc#getDocumentation(String, HttpServletRequest)] 2024-12-14 12:28:15.021 WARN 13142 --- [ restartedMain] c.n.c.sources.URLConfigurationSource : No URLs will be polled as dynamic configuration sources. 2024-12-14 12:28:15.021 INFO 13142 --- [ restartedMain] c.n.c.sources.URLConfigurationSource : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath. 2024-12-14 12:28:15.027 WARN 13142 --- [ restartedMain] c.n.c.sources.URLConfigurationSource : No URLs will be polled as dynamic configuration sources. 2024-12-14 12:28:15.029 INFO 13142 --- [ restartedMain] c.n.c.sources.URLConfigurationSource : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath. 2024-12-14 12:28:16.201 INFO 13142 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8206 (http) with context path '' 2024-12-14 12:28:16.242 INFO 13142 --- [ restartedMain] c.a.c.n.registry.NacosServiceRegistry : nacos registry, DEFAULT_GROUP service-user 192.168.0.102:8206 register finished 2024-12-14 12:28:16.249 INFO 13142 --- [ restartedMain] d.s.w.p.DocumentationPluginsBootstrapper : Documentation plugins bootstrapped 2024-12-14 12:28:16.258 INFO 13142 --- [ restartedMain] d.s.w.p.DocumentationPluginsBootstrapper : Found 2 custom documentation plugin(s) 2024-12-14 12:28:16.341 INFO 13142 --- [ restartedMain] s.d.s.w.s.ApiListingReferenceScanner : Scanning for api listing references 2024-12-14 12:28:16.584 INFO 13142 --- [ restartedMain] s.d.s.w.s.ApiListingReferenceScanner : Scanning for api listing references 2024-12-14 12:28:16.600 INFO 13142 --- [ restartedMain] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: getUserAddressByUserIdUsingGET_1 2024-12-14 12:28:16.609 INFO 13142 --- [ restartedMain] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: loginWxUsingGET_1 2024-12-14 12:28:16.629 INFO 13142 --- [ restartedMain] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: updateUserUsingPOST_1 2024-12-14 12:28:16.650 INFO 13142 --- [ restartedMain] com.youxuan.ssyx.ServiceUserApplication : Started ServiceUserApplication in 11.245 seconds (JVM running for 12.371) ```