3cfa57d6e7cbaa73c570bc5a92a141072ca573e9..5186bf6f2a786775818dc7017ef0bde32cc19201
2025-07-02 zhang
1
5186bf 对比 | 目录
2025-07-02 zhang
1
d6a98e 对比 | 目录
2个文件已修改
27个文件已添加
986 ■■■■■ 已修改文件
.gitignore 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.idea/.gitignore 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.idea/algo-java.iml 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.idea/compiler.xml 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.idea/encodings.xml 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.idea/jarRepositories.xml 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.idea/misc.xml 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.idea/modules.xml 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.idea/vcs.xml 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
LICENSE 201 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
README.md 19 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/pom.xml 92 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/src/main/java/com/zy/entity/User.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/src/main/java/com/zy/service/UserService.java 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rpc-server/pom.xml 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rpc-server/src/main/java/com/zy/SpringBootRpcServerApplication.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rpc-server/src/main/resources/application.yml 84 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rpc-server/target/classes/application.yml 84 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/pom.xml 60 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/src/main/java/com/zy/mapper/UserMapper.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/src/main/java/com/zy/support/UserServiceSupport.java 49 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/src/main/resources/mapper/system/UserMapper.xml 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/target/classes/mapper/system/UserMapper.xml 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
web-server/pom.xml 41 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
web-server/src/main/java/com/zy/SpringBootAplication.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
web-server/src/main/java/com/zy/controller/UserController.java 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
web-server/src/main/resources/application.yml 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
web-server/target/classes/application.properties 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
web-server/target/classes/application.yml 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.gitignore
@@ -1,4 +1,11 @@
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Mobile Tools for Java (J2ME)
.mtj.tmp/
@@ -6,7 +13,11 @@
# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
.idea/.gitignore
New file
@@ -0,0 +1,10 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Environment-dependent path to Maven home directory
/mavenHomeManager.xml
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
.idea/algo-java.iml
New file
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
  <component name="NewModuleRootManager" inherit-compiler-output="true">
    <exclude-output />
    <content url="file://$MODULE_DIR$" />
    <orderEntry type="inheritedJdk" />
    <orderEntry type="sourceFolder" forTests="false" />
  </component>
</module>
.idea/compiler.xml
New file
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="CompilerConfiguration">
    <annotationProcessing>
      <profile default="true" name="Default" enabled="true" />
      <profile name="Maven default annotation processors profile" enabled="true">
        <sourceOutputDir name="target/generated-sources/annotations" />
        <sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
        <outputRelativeToContentRoot value="true" />
        <module name="rpc-server" />
        <module name="api" />
        <module name="web-server" />
        <module name="service" />
      </profile>
    </annotationProcessing>
  </component>
  <component name="JavacSettings">
    <option name="ADDITIONAL_OPTIONS_OVERRIDE">
      <module name="rpc-server" options="-parameters" />
      <module name="web-server" options="-parameters" />
    </option>
  </component>
</project>
.idea/encodings.xml
New file
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="Encoding">
    <file url="file://$PROJECT_DIR$/api/src/main/java" charset="UTF-8" />
    <file url="file://$PROJECT_DIR$/api/src/main/resources" charset="UTF-8" />
    <file url="file://$PROJECT_DIR$/rpc-server/src/main/java" charset="UTF-8" />
    <file url="file://$PROJECT_DIR$/service/src/main/java" charset="UTF-8" />
    <file url="file://$PROJECT_DIR$/service/src/main/resources" charset="UTF-8" />
    <file url="file://$PROJECT_DIR$/web-server/src/main/java" charset="UTF-8" />
  </component>
</project>
.idea/jarRepositories.xml
New file
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="RemoteRepositoriesConfiguration">
    <remote-repository>
      <option name="id" value="central" />
      <option name="name" value="Maven Central repository" />
      <option name="url" value="https://repo1.maven.org/maven2" />
    </remote-repository>
    <remote-repository>
      <option name="id" value="central" />
      <option name="name" value="Central Repository" />
      <option name="url" value="http://maven.aliyun.com/nexus/content/groups/public" />
    </remote-repository>
    <remote-repository>
      <option name="id" value="jboss.community" />
      <option name="name" value="JBoss Community repository" />
      <option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
    </remote-repository>
  </component>
</project>
.idea/misc.xml
New file
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="ExternalStorageConfigurationManager" enabled="true" />
  <component name="KubernetesApiProvider"><![CDATA[{}]]></component>
  <component name="MavenProjectsManager">
    <option name="originalFiles">
      <list>
        <option value="$PROJECT_DIR$/rpc-server/pom.xml" />
        <option value="$PROJECT_DIR$/service/pom.xml" />
        <option value="$PROJECT_DIR$/web-server/pom.xml" />
        <option value="$PROJECT_DIR$/api/pom.xml" />
      </list>
    </option>
  </component>
  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
    <output url="file://$PROJECT_DIR$/out" />
  </component>
</project>
.idea/modules.xml
New file
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="ProjectModuleManager">
    <modules>
      <module fileurl="file://$PROJECT_DIR$/.idea/algo-java.iml" filepath="$PROJECT_DIR$/.idea/algo-java.iml" />
    </modules>
  </component>
</project>
.idea/vcs.xml
New file
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="VcsDirectoryMappings">
    <mapping directory="" vcs="Git" />
  </component>
</project>
LICENSE
New file
@@ -0,0 +1,201 @@
                                 Apache License
                           Version 2.0, January 2004
                        http://www.apache.org/licenses/
   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
   1. Definitions.
      "License" shall mean the terms and conditions for use, reproduction,
      and distribution as defined by Sections 1 through 9 of this document.
      "Licensor" shall mean the copyright owner or entity authorized by
      the copyright owner that is granting the License.
      "Legal Entity" shall mean the union of the acting entity and all
      other entities that control, are controlled by, or are under common
      control with that entity. For the purposes of this definition,
      "control" means (i) the power, direct or indirect, to cause the
      direction or management of such entity, whether by contract or
      otherwise, or (ii) ownership of fifty percent (50%) or more of the
      outstanding shares, or (iii) beneficial ownership of such entity.
      "You" (or "Your") shall mean an individual or Legal Entity
      exercising permissions granted by this License.
      "Source" form shall mean the preferred form for making modifications,
      including but not limited to software source code, documentation
      source, and configuration files.
      "Object" form shall mean any form resulting from mechanical
      transformation or translation of a Source form, including but
      not limited to compiled object code, generated documentation,
      and conversions to other media types.
      "Work" shall mean the work of authorship, whether in Source or
      Object form, made available under the License, as indicated by a
      copyright notice that is included in or attached to the work
      (an example is provided in the Appendix below).
      "Derivative Works" shall mean any work, whether in Source or Object
      form, that is based on (or derived from) the Work and for which the
      editorial revisions, annotations, elaborations, or other modifications
      represent, as a whole, an original work of authorship. For the purposes
      of this License, Derivative Works shall not include works that remain
      separable from, or merely link (or bind by name) to the interfaces of,
      the Work and Derivative Works thereof.
      "Contribution" shall mean any work of authorship, including
      the original version of the Work and any modifications or additions
      to that Work or Derivative Works thereof, that is intentionally
      submitted to Licensor for inclusion in the Work by the copyright owner
      or by an individual or Legal Entity authorized to submit on behalf of
      the copyright owner. For the purposes of this definition, "submitted"
      means any form of electronic, verbal, or written communication sent
      to the Licensor or its representatives, including but not limited to
      communication on electronic mailing lists, source code control systems,
      and issue tracking systems that are managed by, or on behalf of, the
      Licensor for the purpose of discussing and improving the Work, but
      excluding communication that is conspicuously marked or otherwise
      designated in writing by the copyright owner as "Not a Contribution."
      "Contributor" shall mean Licensor and any individual or Legal Entity
      on behalf of whom a Contribution has been received by Licensor and
      subsequently incorporated within the Work.
   2. Grant of Copyright License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      copyright license to reproduce, prepare Derivative Works of,
      publicly display, publicly perform, sublicense, and distribute the
      Work and such Derivative Works in Source or Object form.
   3. Grant of Patent License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      (except as stated in this section) patent license to make, have made,
      use, offer to sell, sell, import, and otherwise transfer the Work,
      where such license applies only to those patent claims licensable
      by such Contributor that are necessarily infringed by their
      Contribution(s) alone or by combination of their Contribution(s)
      with the Work to which such Contribution(s) was submitted. If You
      institute patent litigation against any entity (including a
      cross-claim or counterclaim in a lawsuit) alleging that the Work
      or a Contribution incorporated within the Work constitutes direct
      or contributory patent infringement, then any patent licenses
      granted to You under this License for that Work shall terminate
      as of the date such litigation is filed.
   4. Redistribution. You may reproduce and distribute copies of the
      Work or Derivative Works thereof in any medium, with or without
      modifications, and in Source or Object form, provided that You
      meet the following conditions:
      (a) You must give any other recipients of the Work or
          Derivative Works a copy of this License; and
      (b) You must cause any modified files to carry prominent notices
          stating that You changed the files; and
      (c) You must retain, in the Source form of any Derivative Works
          that You distribute, all copyright, patent, trademark, and
          attribution notices from the Source form of the Work,
          excluding those notices that do not pertain to any part of
          the Derivative Works; and
      (d) If the Work includes a "NOTICE" text file as part of its
          distribution, then any Derivative Works that You distribute must
          include a readable copy of the attribution notices contained
          within such NOTICE file, excluding those notices that do not
          pertain to any part of the Derivative Works, in at least one
          of the following places: within a NOTICE text file distributed
          as part of the Derivative Works; within the Source form or
          documentation, if provided along with the Derivative Works; or,
          within a display generated by the Derivative Works, if and
          wherever such third-party notices normally appear. The contents
          of the NOTICE file are for informational purposes only and
          do not modify the License. You may add Your own attribution
          notices within Derivative Works that You distribute, alongside
          or as an addendum to the NOTICE text from the Work, provided
          that such additional attribution notices cannot be construed
          as modifying the License.
      You may add Your own copyright statement to Your modifications and
      may provide additional or different license terms and conditions
      for use, reproduction, or distribution of Your modifications, or
      for any such Derivative Works as a whole, provided Your use,
      reproduction, and distribution of the Work otherwise complies with
      the conditions stated in this License.
   5. Submission of Contributions. Unless You explicitly state otherwise,
      any Contribution intentionally submitted for inclusion in the Work
      by You to the Licensor shall be under the terms and conditions of
      this License, without any additional terms or conditions.
      Notwithstanding the above, nothing herein shall supersede or modify
      the terms of any separate license agreement you may have executed
      with Licensor regarding such Contributions.
   6. Trademarks. This License does not grant permission to use the trade
      names, trademarks, service marks, or product names of the Licensor,
      except as required for reasonable and customary use in describing the
      origin of the Work and reproducing the content of the NOTICE file.
   7. Disclaimer of Warranty. Unless required by applicable law or
      agreed to in writing, Licensor provides the Work (and each
      Contributor provides its Contributions) on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
      implied, including, without limitation, any warranties or conditions
      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
      PARTICULAR PURPOSE. You are solely responsible for determining the
      appropriateness of using or redistributing the Work and assume any
      risks associated with Your exercise of permissions under this License.
   8. Limitation of Liability. In no event and under no legal theory,
      whether in tort (including negligence), contract, or otherwise,
      unless required by applicable law (such as deliberate and grossly
      negligent acts) or agreed to in writing, shall any Contributor be
      liable to You for damages, including any direct, indirect, special,
      incidental, or consequential damages of any character arising as a
      result of this License or out of the use or inability to use the
      Work (including but not limited to damages for loss of goodwill,
      work stoppage, computer failure or malfunction, or any and all
      other commercial damages or losses), even if such Contributor
      has been advised of the possibility of such damages.
   9. Accepting Warranty or Additional Liability. While redistributing
      the Work or Derivative Works thereof, You may choose to offer,
      and charge a fee for, acceptance of support, warranty, indemnity,
      or other liability obligations and/or rights consistent with this
      License. However, in accepting such obligations, You may act only
      on Your own behalf and on Your sole responsibility, not on behalf
      of any other Contributor, and only if You agree to indemnify,
      defend, and hold each Contributor harmless for any liability
      incurred by, or claims asserted against, such Contributor by reason
      of your accepting any such warranty or additional liability.
   END OF TERMS AND CONDITIONS
   APPENDIX: How to apply the Apache License to your work.
      To apply the Apache License to your work, attach the following
      boilerplate notice, with the fields enclosed by brackets "[]"
      replaced with your own identifying information. (Don't include
      the brackets!)  The text should be enclosed in the appropriate
      comment syntax for the file format. We also recommend that a
      file or class name and description of purpose be included on the
      same "printed page" as the copyright notice for easier
      identification within third-party archives.
   Copyright [yyyy] [name of copyright owner]
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at
       http://www.apache.org/licenses/LICENSE-2.0
   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
README.md
@@ -1,4 +1,19 @@
## algo-java
## 介绍
本项目技术站:
jdk8 + springboot + dubbo + mysql + redis + zookeeper
api模块提供最基础的实体类,枚举类等,最重要是需要暴露出去的抽象接口。
service写具体的接口的实现类,提供具体的实现类。
rpc-server里面是一个启动类,因为依赖service模块,可以理解为生产提供者。
web-server则是主要提供http接口给第三方,如前端调用,也可以引入其他项目的api模块,之后只要有生产者注入到注册中心就可以提供服务了,直接调用api里面的抽象接口方法。
中科大的老师,负责再service模块里写算法即可
1.service已经集成了redis和mysql也都有示例
2.api模块里只要写接口,供第三方系统使用
3.
api/pom.xml
New file
@@ -0,0 +1,92 @@
<?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.zy</groupId>
    <artifactId>api</artifactId>
    <version>1.0-SNAPSHOT</version>
    <properties>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <dubbo.version>2.7.8</dubbo.version>
        <curator.version>4.2.0</curator.version>
        <curator-recipes.version>2.8.0</curator-recipes.version>
        <zookeeper.version>3.6.3</zookeeper.version>
    </properties>
    <dependencies>
        <!-- Dubbo Spring Boot Starter -->
        <dependency>
            <groupId>org.apache.dubbo</groupId>
            <artifactId>dubbo-spring-boot-starter</artifactId>
            <version>2.7.8</version>
        </dependency>
        <!-- Dubbo Spring Boot Starter -->
        <dependency>
            <groupId>org.apache.dubbo</groupId>
            <artifactId>dubbo-spring-boot-starter</artifactId>
            <version>${dubbo.version}</version>
        </dependency>
        <!-- zookeeper注册中心 需要导入zookeeper依赖  -->
        <dependency>
            <groupId>org.apache.zookeeper</groupId>
            <artifactId>zookeeper</artifactId>
            <version>${zookeeper.version}</version>
            <!-- 提示与zookeeper中的slf4j-log4j12-1.7.29.jar 包冲突-->
            <!--排除这个slf4j-log4j12-->
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-log4j12</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>log4j</groupId>
                    <artifactId>log4j</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <!-- Zookeeper 客户端 -->
        <dependency>
            <groupId>org.apache.curator</groupId>
            <artifactId>curator-framework</artifactId>
            <version>${curator.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.curator</groupId>
            <artifactId>curator-recipes</artifactId>
            <version>${curator-recipes.version}</version>
        </dependency>
        <!-- mybatis-plus -->
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus</artifactId>
            <version>3.5.12</version>
        </dependency>
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-generator</artifactId>
            <version>3.4.1</version>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.20</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
</project>
api/src/main/java/com/zy/entity/User.java
New file
@@ -0,0 +1,25 @@
package com.zy.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
@Data
@TableName("sys_user")
public class User implements Serializable {
    private String username;
    /**
     * 密码
     */
    private String password;
    /**
     * 昵称
     */
    private String nickname;
}
api/src/main/java/com/zy/service/UserService.java
New file
@@ -0,0 +1,20 @@
package com.zy.service;
import com.zy.entity.User;
import java.util.List;
//todo 这里写一个自定义注解,之后通过自定义注解来获取该接口和实现类将其注册到注册中心
public interface UserService {
    /**
     * 查询user
     */
    public User queryUser();
    void add(String key, String value);
    String get(String key);
    List<User> getDataByMySql();
}
rpc-server/pom.xml
New file
@@ -0,0 +1,42 @@
<?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>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.5.3</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.zy</groupId>
    <artifactId>rpc-server</artifactId>
    <version>1.0-SNAPSHOT</version>
    <properties>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>com.zy</groupId>
            <artifactId>service</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
    </dependencies>
</project>
rpc-server/src/main/java/com/zy/SpringBootRpcServerApplication.java
New file
@@ -0,0 +1,17 @@
package com.zy;
import com.alibaba.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
@EnableDubbo
public class SpringBootRpcServerApplication {
    public static void main(String[] args) {
        SpringApplication.run(SpringBootRpcServerApplication.class, args);
    }
}
rpc-server/src/main/resources/application.yml
New file
@@ -0,0 +1,84 @@
spring:
  application:
    name: rpc-server
  mvc:
    static-path-pattern: /**
  datasource:
    driver-class-name: com.mysql.jdbc.Driver
    url: jdbc:mysql://localhost:3306/jbly?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
    username: root
    password: xltys1995
    type: com.alibaba.druid.pool.DruidDataSource
    druid:
      initial-size: 5
      min-idle: 5
      max-active: 20
      max-wait: 30000
      time-between-eviction-runs-millis: 60000
      min-evictable-idle-time-millis: 300000
      test-while-idle: true
      test-on-borrow: true
      test-on-return: false
      remove-abandoned: true
      remove-abandoned-timeout: 1800
      #pool-prepared-statements: false
      #max-pool-prepared-statement-per-connection-size: 20
      filters: stat, wall
      validation-query: SELECT 'x'
      aop-patterns: com.zy.*.*.service.*
      stat-view-servlet:
        url-pattern: /druid/*
        reset-enable: true
        login-username: admin
        login-password: admin
        enabled: true
  servlet:
    multipart:
      maxFileSize: 100MB
      maxRequestSize: 100MB
  jmx:
    enabled: false
  redis:
    host: localhost
    password: xltys1995
    port: 6379
    max: 30
    min: 10
    timeout: 5000
    index: 3
server:
  port: 8082
dubbo:
  application:
    name: rpc-server
  registry:
    address: zookeeper://127.0.0.1:2181
    # protocol: zookeeper
    # password: dreamtech
    # username: zk_user
  protocol:
    name: dubbo
    port: 20880
  monitor:
    protocol: registry
mybatis-plus:
  mapper-locations: classpath:mapper/*/*.xml
  #  global-config:
  #    field-strategy: 0
  configuration:
    #    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
    map-underscore-to-camel-case: true
    cache-enabled: true
  global-config:
    :banner: false
    db-config:
      id-type: auto
      logic-delete-value: 1
      logic-not-delete-value: 0
rpc-server/target/classes/application.yml
New file
@@ -0,0 +1,84 @@
spring:
  application:
    name: rpc-server
  mvc:
    static-path-pattern: /**
  datasource:
    driver-class-name: com.mysql.jdbc.Driver
    url: jdbc:mysql://localhost:3306/jbly?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
    username: root
    password: xltys1995
    type: com.alibaba.druid.pool.DruidDataSource
    druid:
      initial-size: 5
      min-idle: 5
      max-active: 20
      max-wait: 30000
      time-between-eviction-runs-millis: 60000
      min-evictable-idle-time-millis: 300000
      test-while-idle: true
      test-on-borrow: true
      test-on-return: false
      remove-abandoned: true
      remove-abandoned-timeout: 1800
      #pool-prepared-statements: false
      #max-pool-prepared-statement-per-connection-size: 20
      filters: stat, wall
      validation-query: SELECT 'x'
      aop-patterns: com.zy.*.*.service.*
      stat-view-servlet:
        url-pattern: /druid/*
        reset-enable: true
        login-username: admin
        login-password: admin
        enabled: true
  servlet:
    multipart:
      maxFileSize: 100MB
      maxRequestSize: 100MB
  jmx:
    enabled: false
  redis:
    host: localhost
    password: xltys1995
    port: 6379
    max: 30
    min: 10
    timeout: 5000
    index: 3
server:
  port: 8082
dubbo:
  application:
    name: rpc-server
  registry:
    address: zookeeper://127.0.0.1:2181
    # protocol: zookeeper
    # password: dreamtech
    # username: zk_user
  protocol:
    name: dubbo
    port: 20880
  monitor:
    protocol: registry
mybatis-plus:
  mapper-locations: classpath:mapper/*/*.xml
  #  global-config:
  #    field-strategy: 0
  configuration:
    #    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
    map-underscore-to-camel-case: true
    cache-enabled: true
  global-config:
    :banner: false
    db-config:
      id-type: auto
      logic-delete-value: 1
      logic-not-delete-value: 0
service/pom.xml
New file
@@ -0,0 +1,60 @@
<?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.zy</groupId>
    <artifactId>service</artifactId>
    <version>1.0-SNAPSHOT</version>
    <properties>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <dependencies>
        <dependency>
            <groupId>com.zy</groupId>
            <artifactId>api</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
        <!-- 集成redis依赖  -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis</artifactId>
            <version>2.0.3.RELEASE</version>
        </dependency>
        <!-- mybatis-plus -->
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>3.4.1</version>
        </dependency>
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-generator</artifactId>
            <version>3.4.1</version>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.47</version>
        </dependency>
        <!-- druid -->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid-spring-boot-starter</artifactId>
            <version>1.2.6</version>
        </dependency>
    </dependencies>
</project>
service/src/main/java/com/zy/mapper/UserMapper.java
New file
@@ -0,0 +1,13 @@
package com.zy.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zy.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
@Mapper
@Repository
public interface UserMapper extends BaseMapper<User> {
}
service/src/main/java/com/zy/support/UserServiceSupport.java
New file
@@ -0,0 +1,49 @@
package com.zy.support;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zy.entity.User;
import com.zy.mapper.UserMapper;
import com.zy.service.UserService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import java.util.List;
@DubboService // 该注解用于将当前类对象存入spring容器中,既可以本项目服务使用,父接口注解能力也可以提供给其他项目使用
public class UserServiceSupport implements UserService {
    @Autowired
    private RedisTemplate<String, String> redisTemplate;
    @Autowired
    private UserMapper userMapper;
    /**
     * 查询user
     */
    @Override
    public User queryUser() {
        User user = new User();
        user.setNickname("1212");
        user.setUsername("张三");
        return user;
    }
    @Override
    public void add(String key, String value) {
        redisTemplate.opsForValue().set(key, value);
    }
    @Override
    public String get(String key) {
        return redisTemplate.opsForValue().get(key);
    }
    @Override
    public List<User> getDataByMySql() {
        List<User> users = userMapper.selectList(new QueryWrapper<>());
        return users;
    }
}
service/src/main/resources/mapper/system/UserMapper.xml
New file
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zy.mapper.UserMapper">
</mapper>
service/target/classes/mapper/system/UserMapper.xml
New file
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zy.mapper.UserMapper">
</mapper>
web-server/pom.xml
New file
@@ -0,0 +1,41 @@
<?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>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.5.3</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.zy</groupId>
    <artifactId>web-server</artifactId>
    <version>1.0-SNAPSHOT</version>
    <properties>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>com.zy</groupId>
            <artifactId>api</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
    </dependencies>
</project>
web-server/src/main/java/com/zy/SpringBootAplication.java
New file
@@ -0,0 +1,17 @@
package com.zy;
import com.alibaba.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
@EnableDubbo
public class SpringBootAplication {
    public static void main(String[] args) {
        SpringApplication.run(SpringBootAplication.class, args);
    }
}
web-server/src/main/java/com/zy/controller/UserController.java
New file
@@ -0,0 +1,42 @@
package com.zy.controller;
import com.zy.entity.User;
import com.zy.service.UserService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
public class UserController {
    @DubboReference(timeout = 1000, check = false)//远程注入
    private UserService userService;
    @GetMapping("/user")
    public String user() {
        User user = userService.queryUser();
        return user.toString();
    }
    @GetMapping("/get")
    public String get() {
        return userService.get("user");
    }
    @GetMapping("/add")
    public String add() {
        userService.add("user", "123");
        return "ok";
    }
    @GetMapping("/user3")
    public List<User> user3() {
        return userService.getDataByMySql();
    }
}
web-server/src/main/resources/application.yml
New file
@@ -0,0 +1,19 @@
spring:
  application:
    name: web-server
server:
  port: 8083
dubbo:
  protocol:
    name: dubbo
    port: 20885
  application:
    name: web-server
  registry:
    address: zookeeper://127.0.0.1:2181
    # password: dreamtech
    # username: zk_user
  monitor:
    protocol: registry
web-server/target/classes/application.properties
New file
@@ -0,0 +1,14 @@
# ????
spring.application.name=web-server
# ???? WEB ????
server.port=8083
dubbo.protocol.name=dubbo
dubbo.application.name=web-server
dubbo.registry.address=zookeeper://127.0.0.1:2181
#dubbo.registry.password=dreamtech
#dubbo.registry.username=zk_user
dubbo.monitor.protocol=registry
dubbo.protocol.port=20885
web-server/target/classes/application.yml
New file
@@ -0,0 +1,19 @@
spring:
  application:
    name: web-server
server:
  port: 8083
dubbo:
  protocol:
    name: dubbo
    port: 20885
  application:
    name: web-server
  registry:
    address: zookeeper://127.0.0.1:2181
    # password: dreamtech
    # username: zk_user
  monitor:
    protocol: registry