模块化

This commit is contained in:
anran.war 2021-12-09 19:47:09 +08:00 committed by anruence
parent 164d3ec824
commit 6226b57e8e
902 changed files with 1776 additions and 2919 deletions

51
.gitignore vendored
View File

@ -1,53 +1,14 @@
# Created by .ignore support plugin (hsz.mobi)
### Example user template template
### Example user template
# IntelliJ project files
.DS_Store
.idea
.idea/
*.iml
.mvn/*
out
gen### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# CMake
cmake-build-*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.iws
# IntelliJ
out/
@ -57,17 +18,12 @@ out/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
### Java template
# Compiled class file
*.class
@ -88,6 +44,8 @@ fabric.properties
*.zip
*.tar.gz
*.rar
.settings/
.mvn/
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
@ -100,4 +58,3 @@ pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties

View File

@ -1 +0,0 @@
两次md5

Binary file not shown.

View File

@ -1 +0,0 @@
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip

View File

@ -4,7 +4,7 @@
<parent>
<groupId>com.geekq</groupId>
<artifactId>miaosha-admin</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>${revision}</version>
</parent>
<artifactId>miaosha-admin-api</artifactId>
@ -30,8 +30,8 @@
<!--</dependency>-->
<dependency>
<groupId>com.geekq</groupId>
<artifactId>miaosha-common</artifactId>
<version>0.0.1-SNAPSHOT</version>
<artifactId>miaosha-admin-common</artifactId>
<version>${revision}</version>
</dependency>

View File

@ -4,9 +4,10 @@
<parent>
<groupId>com.geekq</groupId>
<artifactId>miaosha-admin</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>${revision}</version>
</parent>
<artifactId>miaosha-common</artifactId>
<artifactId>miaosha-admin-common</artifactId>
<version>${revision}</version>
<properties>
<org.mybatis.version>3.2.3</org.mybatis.version>
<org.springframework.version>4.0.0.RELEASE</org.springframework.version>
@ -18,10 +19,6 @@
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>

View File

@ -4,7 +4,7 @@
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<dependent-module archiveName="imooc-dubbo-order-api-0.0.1-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/imooc-dubbo-order-api/imooc-dubbo-order-api">
<dependent-module archiveName="imooc-dubbo-order-api-${revision}.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/imooc-dubbo-order-api/imooc-dubbo-order-api">
<dependency-type>uses</dependency-type>
</dependent-module>
<property name="context-root" value="imooc-dubbo-order-service"/>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>com.geekq</groupId>
<artifactId>miaosha-admin</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>${revision}</version>
</parent>
<artifactId>miaosha-admin-service</artifactId>
@ -12,23 +12,16 @@
<dependencies>
<!-- jedis依赖 -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
<version>1.8.4.RELEASE</version>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>2.9.0</version>
</dependency>
<dependency>
<groupId>com.geekq</groupId>
<artifactId>miaosha-admin-api</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>${revision}</version>
</dependency>
<dependency>

View File

@ -4,13 +4,13 @@
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<dependent-module archiveName="imooc-dubbo-common-0.0.1-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/imooc-dubbo-common/imooc-dubbo-common">
<dependent-module archiveName="imooc-dubbo-common-${revision}.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/imooc-dubbo-common/imooc-dubbo-common">
<dependency-type>uses</dependency-type>
</dependent-module>
<dependent-module archiveName="imooc-dubbo-item-api-0.0.1-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/imooc-dubbo-item-api/imooc-dubbo-item-api">
<dependent-module archiveName="imooc-dubbo-item-api-${revision}.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/imooc-dubbo-item-api/imooc-dubbo-item-api">
<dependency-type>uses</dependency-type>
</dependent-module>
<dependent-module archiveName="imooc-dubbo-order-api-0.0.1-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/imooc-dubbo-order-api/imooc-dubbo-order-api">
<dependent-module archiveName="imooc-dubbo-order-api-${revision}.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/imooc-dubbo-order-api/imooc-dubbo-order-api">
<dependency-type>uses</dependency-type>
</dependent-module>
<property name="context-root" value="imooc-dubbo-web"/>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>com.geekq</groupId>
<artifactId>miaosha-admin</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>${revision}</version>
</parent>
<artifactId>miaosha-admin-web</artifactId>
@ -13,19 +13,18 @@
<dependencies>
<dependency>
<groupId>com.geekq</groupId>
<artifactId>miaosha-common</artifactId>
<version>0.0.1-SNAPSHOT</version>
<artifactId>miaosha-admin-common</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>com.geekq</groupId>
<artifactId>miaosha-admin-api</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>com.geekq</groupId>
<artifactId>miaosha-admin-service</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>${revision}</version>
</dependency>
<!-- freemarker -->
<dependency>

View File

@ -3,9 +3,14 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.geekq</groupId>
<artifactId>miaosha-admin</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>${revision}</version>
<packaging>pom</packaging>
<parent>
<groupId>com.geekq</groupId>
<artifactId>miaosha-parent</artifactId>
<version>${revision}</version>
<relativePath>../pom.xml</relativePath>
</parent>
<!-- 集中定义依赖版本号 -->
<properties>
<spring.version>4.3.13.RELEASE</spring.version>
@ -23,7 +28,6 @@
<servlet-api.version>2.5</servlet-api.version>
<jsp-api.version>2.0</jsp-api.version>
<commons-lang3.version>3.3.2</commons-lang3.version>
<commons-io.version>1.3.2</commons-io.version>
<commons-net.version>3.3</commons-net.version>
<pagehelper.version>4.1.3</pagehelper.version>
<jsqlparser.version>0.9.1</jsqlparser.version>
@ -39,24 +43,6 @@
<!-- 只定义依赖的版本,不会实际依赖 -->
<dependencyManagement>
<dependencies>
<!--<dependency>-->
<!--<groupId>org.springframework</groupId>-->
<!--<artifactId>spring-jms</artifactId>-->
<!--<version>${spring.version}</version>-->
<!--</dependency>-->
<!-- Apache工具组件 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons-lang3.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
<version>${commons-io.version}</version>
</dependency>
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
@ -145,12 +131,6 @@
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<!--<dependency>-->
<!--<groupId>org.springframework</groupId>-->
<!--<artifactId>spring-web</artifactId>-->
<!--<version>4.0.0.RELEASE</version>-->
<!--</dependency>-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
@ -298,7 +278,7 @@
</build>
<modules>
<module>miaosha-common</module>
<module>miaosha-admin-common</module>
<module>miaosha-admin-api</module>
<module>miaosha-admin-service</module>
<module>miaosha-admin-web</module>

View File

@ -5,7 +5,19 @@
<groupId>com.geekq.api</groupId>
<artifactId>miaosha-order-api</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>${revision}</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>7</source>
<target>7</target>
</configuration>
</plugin>
</plugins>
</build>
<name>miaosha-order-api</name>
<description>Dubbo api for Spring Boot</description>
@ -13,6 +25,6 @@
<parent>
<groupId>com.geekq.dubbo</groupId>
<artifactId>miaosha-order</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>${revision}</version>
</parent>
</project>

View File

@ -2,21 +2,19 @@
<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>com.geekq.dubbo</groupId>
<artifactId>miaosha-order</artifactId>
<version>${revision}</version>
</parent>
<groupId>com.geekq.provider</groupId>
<artifactId>miaosha-order-provider</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>${revision}</version>
<packaging>jar</packaging>
<name>miaosha-order-provider</name>
<description>Dubbo provider for Spring Boot</description>
<parent>
<groupId>com.geekq.dubbo</groupId>
<artifactId>miaosha-order</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
@ -27,7 +25,7 @@
<dependency>
<groupId>com.geekq.api</groupId>
<artifactId>miaosha-order-api</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>${revision}</version>
</dependency>
</dependencies>

View File

@ -2,27 +2,22 @@
<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>com.geekq</groupId>
<artifactId>miaosha-parent</artifactId>
<version>${revision}</version>
<relativePath>../pom.xml</relativePath>
</parent>
<groupId>com.geekq.dubbo</groupId>
<artifactId>miaosha-order</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>${revision}</version>
<packaging>pom</packaging>
<name>${project.artifactId}</name>
<modules>
<module>miaosha-order-api</module>
<module>miaosha-order-provider</module>
</modules>
<name>miaosha-order</name>
<description>Dubbo springboot for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
@ -46,64 +41,38 @@
<version>1.18.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>${org.mybatis.version}</version>
</dependency>
<!--<dependency>-->
<!--<groupId>com.geekq</groupId>-->
<!--<artifactId>miaosha-common</artifactId>-->
<!--<version>0.0.1-SNAPSHOT</version>-->
<!--</dependency>-->
<dependency>
<groupId>com.alibaba.boot</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
<version>${dubbo.starter.version}</version>
</dependency>
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-framework</artifactId>
<version>${curator-framework.version}</version>
</dependency>
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>${zookeeper.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>${com.alibaba.druid}</version>
</dependency>
</dependencies>
<build>
<!--<plugins>-->
<!--<plugin>-->
<!--<groupId>org.springframework.boot</groupId>-->
<!--<artifactId>spring-boot-maven-plugin</artifactId>-->
<!--</plugin>-->
<!--</plugins>-->
</build>
</project>

View File

@ -0,0 +1,26 @@
<?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>
<groupId>com.geekq</groupId>
<artifactId>miaosha-rpc</artifactId>
<version>${revision}</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>dubbo-api</artifactId>
<name>${project.artifactId}</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -1,7 +1,6 @@
package com.geekq.dubbo.springboot;
import dto.CapitalTradeOrderDto;
import org.mengyun.tcctransaction.api.Compensable;
import java.math.BigDecimal;
@ -9,11 +8,7 @@ import java.math.BigDecimal;
* @author qiurunze
*/
public interface CapAccountTradeOrderService {
BigDecimal getCapAccountByUserId(Long userId);
BigDecimal getCapAccountByUserId(Long userId );
@Compensable
public String record(CapitalTradeOrderDto tradeOrderDto);
}

View File

@ -1,10 +1,7 @@
package com.geekq.dubbo.springboot;
import org.mengyun.tcctransaction.api.Compensable;
public interface ServiceAPI {
@Compensable
String sendMessage(String message);
/*
@ -20,17 +17,12 @@ public interface ServiceAPI {
*/
// 判断是否为真座位
@Compensable
boolean isTrueSeats(String seats);
// 是否已售
@Compensable
boolean isNotSold(String seats);
// 保存订单
@Compensable
String saveOrder(String fieldId,String seats,String seatsNum);
String saveOrder(String fieldId, String seats, String seatsNum);
}

View File

@ -2,33 +2,31 @@
<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.geekq.dubbo.springboot</groupId>
<artifactId>consumer</artifactId>
<version>0.0.1-SNAPSHOT</version>
<parent>
<groupId>com.geekq</groupId>
<artifactId>miaosha-rpc</artifactId>
<version>${revision}</version>
</parent>
<artifactId>dubbo-consumer</artifactId>
<version>${revision}</version>
<packaging>jar</packaging>
<name>consumer</name>
<name>${project.artifactId}</name>
<description>服务消费者</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>com.geekq</groupId>
<artifactId>dubbo-api</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.spring.boot</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
@ -44,31 +42,6 @@
<artifactId>zkclient</artifactId>
<version>0.10</version>
</dependency>
<dependency>
<groupId>com.geekq.dubbo.springboot</groupId>
<artifactId>dubbo-api</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.mengyun</groupId>
<artifactId>tcc-transaction-dubbo</artifactId>
<version>1.2.4.24</version>
</dependency>
<dependency>
<groupId>org.mengyun</groupId>
<artifactId>tcc-transaction-spring</artifactId>
<version>1.2.4.24</version>
</dependency>
<dependency>
<groupId>org.mengyun</groupId>
<artifactId>tcc-transaction-core</artifactId>
<version>1.2.4.24</version>
</dependency>
<dependency>
<groupId>org.mengyun</groupId>
<artifactId>tcc-transaction-api</artifactId>
<version>1.2.4.24</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
@ -87,12 +60,6 @@
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>2.2.1</version>
<exclusions>
<exclusion>
<artifactId>slf4j-api</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
@ -105,7 +72,6 @@
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>23.0</version>
</dependency>
<dependency>
<groupId>com.esotericsoftware</groupId>
@ -115,14 +81,12 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.8.1</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.51</version>
</dependency>
</dependencies>
<build>

View File

@ -0,0 +1,7 @@
package com.geekq.dubbo.springboot.consumer.config;
import org.springframework.context.annotation.Configuration;
@Configuration
public class TCCConfig {
}

View File

@ -9,10 +9,8 @@ public class QuickstartConsumer {
@Reference(interfaceClass = ServiceAPI.class)
ServiceAPI serviceAPI;
public void sendMessage(String message){
public void sendMessage(String message) {
System.out.println(serviceAPI.sendMessage(message));
}
}

View File

@ -1,7 +1,6 @@
package com.geekq.dubbo.springboot.consumer.transaction;
import com.geekq.dubbo.springboot.ServiceAPI;
import org.mengyun.tcctransaction.api.Compensable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@ -9,16 +8,15 @@ import org.springframework.stereotype.Component;
public class TransactionConsumer {
@Autowired
ServiceAPI serviceAPI;
private ServiceAPI serviceAPI;
@Compensable(confirmMethod = "confirmSendMessage", cancelMethod = "cancelSendMessage", asyncConfirm = true)
public void sendMessage(String message){
public void sendMessage(String message) {
// System.out.println("this is consumer sendMessage message="+message);
//
// System.out.println(serviceAPI.sendMessage(message));
// 测试业务
serviceAPI.saveOrder("001",message,"5");
serviceAPI.saveOrder("001", message, "5");
serviceAPI.isTrueSeats(message);
@ -26,13 +24,13 @@ public class TransactionConsumer {
}
public void confirmSendMessage(String message){
System.out.println("this is consumer confirmSendMessage message="+message);
public void confirmSendMessage(String message) {
System.out.println("this is consumer confirmSendMessage message=" + message);
// System.out.println(serviceAPI.sendMessage(message));
}
public void cancelSendMessage(String message){
System.out.println("this is consumer cancelSendMessage message="+message);
public void cancelSendMessage(String message) {
System.out.println("this is consumer cancelSendMessage message=" + message);
// System.out.println(serviceAPI.sendMessage(message));
}
}

View File

@ -2,22 +2,18 @@
<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.geekq.dubbo.springboot</groupId>
<artifactId>privoder</artifactId>
<version>0.0.1-SNAPSHOT</version>
<parent>
<groupId>com.geekq</groupId>
<artifactId>miaosha-rpc</artifactId>
<version>${revision}</version>
</parent>
<artifactId>dubbo-provider</artifactId>
<version>${revision}</version>
<packaging>jar</packaging>
<name>privoder</name>
<name>${project.artifactId}</name>
<description>服务提供者</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
@ -29,6 +25,10 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>com.geekq</groupId>
<artifactId>dubbo-api</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.spring.boot</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
@ -44,31 +44,6 @@
<artifactId>zkclient</artifactId>
<version>0.10</version>
</dependency>
<dependency>
<groupId>com.geekq.dubbo.springboot</groupId>
<artifactId>dubbo-api</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.mengyun</groupId>
<artifactId>tcc-transaction-dubbo</artifactId>
<version>1.2.4.24</version>
</dependency>
<dependency>
<groupId>org.mengyun</groupId>
<artifactId>tcc-transaction-spring</artifactId>
<version>1.2.4.24</version>
</dependency>
<dependency>
<groupId>org.mengyun</groupId>
<artifactId>tcc-transaction-core</artifactId>
<version>1.2.4.24</version>
</dependency>
<dependency>
<groupId>org.mengyun</groupId>
<artifactId>tcc-transaction-api</artifactId>
<version>1.2.4.24</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
@ -77,7 +52,6 @@
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.10</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>

View File

@ -0,0 +1,7 @@
package com.geekq.dubbo.springboot.privoder.config;
import org.springframework.context.annotation.Configuration;
@Configuration
public class TCCConfig {
}

View File

@ -1,5 +1,6 @@
package com.geekq.dubbo.springboot.privoder.quickstart;
import com.geekq.dubbo.springboot.ServiceAPI;
//@Component
@ -8,7 +9,7 @@ public class QuickstartServiceImpl implements ServiceAPI {
@Override
public String sendMessage(String message) {
return "quickstart-provider-message="+message;
return "quickstart-provider-message=" + message;
}
@Override

View File

@ -2,8 +2,6 @@ package com.geekq.dubbo.springboot.privoder.transaction;
import com.alibaba.dubbo.config.annotation.Service;
import com.geekq.dubbo.springboot.ServiceAPI;
import org.mengyun.tcctransaction.api.Compensable;
import org.mengyun.tcctransaction.dubbo.context.DubboTransactionContextEditor;
import org.springframework.stereotype.Component;
@Component
@ -11,57 +9,53 @@ import org.springframework.stereotype.Component;
public class TransactionServiceImpl implements ServiceAPI {
@Override
@Compensable(confirmMethod = "confirmSendMessage", cancelMethod = "cancelSendMessage", transactionContextEditor = DubboTransactionContextEditor.class)
public String sendMessage(String message) {
System.out.println("this is sendMessage try message="+message);
if(message.equals("123")){
System.out.println("this is sendMessage try message=" + message);
if (message.equals("123")) {
throw new NullPointerException();
}
return "quickstart-provider-message="+message;
return "quickstart-provider-message=" + message;
}
@Override
@Compensable(confirmMethod = "confirmIsTrueSeats", cancelMethod = "cancelIsTrueSeats", transactionContextEditor = DubboTransactionContextEditor.class)
public boolean isTrueSeats(String seats) {
if(seats.equals("1,2,3")){
if (seats.equals("1,2,3")) {
throw new IllegalArgumentException();
}else{
} else {
return true;
}
}
@Override
@Compensable(confirmMethod = "confirmIsNotSold", cancelMethod = "cancelIsNotSold", transactionContextEditor = DubboTransactionContextEditor.class)
public boolean isNotSold(String seats) {
if(seats.equals("4,5")){
if (seats.equals("4,5")) {
throw new IllegalArgumentException();
}else{
} else {
return true;
}
}
/*
千万千万注意幂等性问题
/**
* 千万千万注意幂等性问题
*/
@Override
@Compensable(confirmMethod = "confirmSaveOrder", cancelMethod = "cancelSaveOrder", transactionContextEditor = DubboTransactionContextEditor.class)
public String saveOrder(String fieldId, String seats, String seatsNum) {
System.out.println("创建一个待支付状态的订单");
return "";
}
public String confirmSaveOrder(String fieldId, String seats, String seatsNum) {
System.out.println("将订单修改为支付中");
return "";
}
public String cancelSaveOrder(String fieldId, String seats, String seatsNum) {
System.out.println("将订单修改为已关闭");
return "";
}
public String confirmSendMessage(String message) {
System.out.println("this is confirmSendMessage message="+message);
return "quickstart-provider-message="+message;
System.out.println("this is confirmSendMessage message=" + message);
return "quickstart-provider-message=" + message;
}
public String cancelSendMessage(String message) {
@ -73,14 +67,17 @@ public class TransactionServiceImpl implements ServiceAPI {
System.out.println("this is confirmIsTrueSeats");
return true;
}
public boolean cancelIsTrueSeats(String seats) {
System.out.println("this is cancelIsTrueSeats");
return true;
}
public boolean confirmIsNotSold(String seats) {
System.out.println("this is confirmIsNotSold");
return true;
}
public boolean cancelIsNotSold(String seats) {
System.out.println("this is cancelIsNotSold");
return true;

45
miaosha-rpc/pom.xml Normal file
View File

@ -0,0 +1,45 @@
<?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.geekq</groupId>
<artifactId>miaosha-rpc</artifactId>
<version>${revision}</version>
<modules>
<module>dubbo-api</module>
<module>dubbo-consumer</module>
<module>dubbo-provider</module>
</modules>
<packaging>pom</packaging>
<name>${project.artifactId}</name>
<description>SpringBoot与Dubbo集成测试单元</description>
<parent>
<groupId>com.geekq</groupId>
<artifactId>miaosha-parent</artifactId>
<version>${revision}</version>
<relativePath>../pom.xml</relativePath>
</parent>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.geekq</groupId>
<artifactId>dubbo-api</artifactId>
<version>${revision}</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

195
miaosha-v1/pom.xml Normal file
View File

@ -0,0 +1,195 @@
<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>com.geekq</groupId>
<artifactId>miaosha-parent</artifactId>
<version>${revision}</version>
<relativePath>../pom.xml</relativePath>
</parent>
<groupId>com.geekq.v1</groupId>
<artifactId>miaosha-v1</artifactId>
<version>${revision}</version>
<name>${project.artifactId}</name>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>com.github.sgroschupf</groupId>
<artifactId>zkclient</artifactId>
<version>0.1</version>
</dependency>
<!-- zk 客户端依赖 -->
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-framework</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-recipes</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>dubbo</artifactId>
<version>2.5.3</version>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>3.4.6</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<!--打包的时候可以不用包进去,别的设施会提供。事实上该依赖理论上可以参与编译,测试,运行等周期。
相当于compile但是打包阶段做了exclude操作-->
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>31.0.1-jre</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.2.0</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<!--<dependency>-->
<!--<groupId>com.geekq.dubbo.springboot</groupId>-->
<!--<artifactId>miaosha-rely</artifactId>-->
<!--<version>${revision}</version>-->
<!--</dependency>-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.2.8</version>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.10.13</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.22</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-test</artifactId>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>miaosha-v1/src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
<resource>
<directory>miaosha-v1/src/main/resources</directory>
<filtering>true</filtering>
<excludes>
<exclude>application-local.properties</exclude>
<exclude>application-dev.properties</exclude>
<exclude>application-prod.properties</exclude>
<exclude>application-test.properties</exclude>
</excludes>
</resource>
<resource>
<directory>miaosha-v1/src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>application-${activatedProperties}.properties</include>
<include>application.properties</include>
</includes>
</resource>
</resources>
</build>
</project>

View File

@ -3,7 +3,6 @@ package com.geekq.miaosha.access;
import com.alibaba.fastjson.JSON;
import com.geekq.miaosha.common.enums.ResultStatus;
import com.geekq.miaosha.common.resultbean.ResultGeekQ;
import com.geekq.miaosha.controller.LoginController;
import com.geekq.miaosha.domain.MiaoshaUser;
import com.geekq.miaosha.redis.RedisService;
import com.geekq.miaosha.service.MiaoShaUserService;

View File

@ -8,7 +8,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.thymeleaf.context.WebContext;
import org.thymeleaf.spring4.view.ThymeleafViewResolver;
import org.thymeleaf.spring5.view.ThymeleafViewResolver;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

View File

@ -18,8 +18,7 @@ import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.thymeleaf.spring4.context.SpringWebContext;
import org.thymeleaf.spring4.view.ThymeleafViewResolver;
import org.thymeleaf.spring5.view.ThymeleafViewResolver;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@ -93,13 +92,13 @@ public class GoodsController extends BaseController {
model.addAttribute("miaoshaStatus", miaoshaStatus);
model.addAttribute("remainSeconds", remainSeconds);
// return "goods_detail";
SpringWebContext ctx = new SpringWebContext(request,response,
request.getServletContext(),request.getLocale(), model.asMap(), applicationContext );
html = viewResolver.getTemplateEngine().process("goods_detail", ctx);
if(!StringUtils.isEmpty(html)) {
redisService.set(GoodsKey.getGoodsDetail, ""+goodsId, html);
}
//TODO support spring5
// SpringWebContext ctx = new SpringWebContext(request,response,
// request.getServletContext(),request.getLocale(), model.asMap(), applicationContext );
// html = viewResolver.getTemplateEngine().process("goods_detail", ctx);
// if(!StringUtils.isEmpty(html)) {
// redisService.set(GoodsKey.getGoodsDetail, ""+goodsId, html);
// }
return html;
}

Some files were not shown because too many files have changed in this diff Show More