xuzuoyun пре 5 година
комит
8cecb39823

+ 2 - 0
.idea/.gitignore

@@ -0,0 +1,2 @@
+# Default ignored files
+/workspace.xml

+ 13 - 0
.idea/compiler.xml

@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="CompilerConfiguration">
+    <annotationProcessing>
+      <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="bytedance" />
+      </profile>
+    </annotationProcessing>
+  </component>
+</project>

+ 7 - 0
.idea/encodings.xml

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="Encoding">
+    <file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
+    <file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
+  </component>
+</project>

+ 14 - 0
.idea/misc.xml

@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ExternalStorageConfigurationManager" enabled="true" />
+  <component name="MavenProjectsManager">
+    <option name="originalFiles">
+      <list>
+        <option value="$PROJECT_DIR$/pom.xml" />
+      </list>
+    </option>
+  </component>
+  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
+    <output url="file://$PROJECT_DIR$/out" />
+  </component>
+</project>

+ 2 - 0
bytedance.iml

@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="JAVA_MODULE" version="4" />

+ 87 - 0
pom.xml

@@ -0,0 +1,87 @@
+<?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>cn.com.ctop</groupId>
+    <artifactId>bytedance</artifactId>
+    <version>1.0-SNAPSHOT</version>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+        <maven.compiler.encoding>UTF-8</maven.compiler.encoding>
+        <maven.compiler.source>1.7</maven.compiler.source>
+        <maven.compiler.target>1.7</maven.compiler.target>
+        <maven.test.skip>true</maven.test.skip>
+
+        <xxl-rpc.version>1.3.2</xxl-rpc.version>
+
+        <spring.version>4.3.22.RELEASE</spring.version>
+
+        <spring-boot.version>1.5.19.RELEASE</spring-boot.version>
+        <mybatis-spring-boot-starter.version>1.3.3</mybatis-spring-boot-starter.version>
+        <mysql-connector-java.version>5.1.47</mysql-connector-java.version>
+
+    </properties>
+    <dependencyManagement>
+        <dependencies>
+            <dependency>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-starter-parent</artifactId>
+                <version>${spring-boot.version}</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+
+
+    <dependencies>
+
+        <!-- starter-web:spring-webmvc + autoconfigure + logback + yaml + tomcat -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+        <!-- starter-test:junit + spring-test + mockito -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <!-- freemarker-starter -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-freemarker</artifactId>
+        </dependency>
+
+        <!-- xxl-mq-client -->
+        <dependency>
+            <groupId>com.xuxueli</groupId>
+            <artifactId>xxl-mq-client</artifactId>
+            <version>1.3.0-SNAPSHOT</version>
+        </dependency>
+
+    </dependencies>
+
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <version>${spring-boot.version}</version>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>repackage</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+</project>

+ 11 - 0
src/main/java/cn/com/ctop/bytedance/MainApplication.java

@@ -0,0 +1,11 @@
+package cn.com.ctop.bytedance;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class MainApplication {
+    public static void main(String[] args) {
+        SpringApplication.run(MainApplication.class, args);
+    }
+}

+ 24 - 0
src/main/java/cn/com/ctop/bytedance/comsumer/BytednaceAuthComsumer.java

@@ -0,0 +1,24 @@
+package cn.com.ctop.bytedance.comsumer;
+
+import com.xxl.mq.client.consumer.IMqConsumer;
+import com.xxl.mq.client.consumer.MqResult;
+import com.xxl.mq.client.consumer.annotation.MqConsumer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+/**
+ * Created by xuxueli on 16/8/28.
+ */
+@MqConsumer(topic = "bytedance_auth")
+@Service
+public class BytednaceAuthComsumer implements IMqConsumer {
+    private Logger logger = LoggerFactory.getLogger(BytednaceAuthComsumer.class);
+
+    @Override
+    public MqResult consume(String data) throws Exception {
+        logger.info("[BytednaceAuthComsumer] 消费一条消息:{}", data);
+        return MqResult.SUCCESS;
+    }
+
+}

+ 29 - 0
src/main/java/cn/com/ctop/bytedance/conf/XxlMqConf.java

@@ -0,0 +1,29 @@
+package cn.com.ctop.bytedance.conf;
+
+import com.xxl.mq.client.factory.impl.XxlMqSpringClientFactory;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.stereotype.Component;
+
+@Component
+public class XxlMqConf {
+
+    // ---------------------- param ----------------------
+
+    @Value("${xxl.mq.admin.address}")
+    private String adminAddress;
+    @Value("${xxl.mq.accessToken}")
+    private String accessToken;
+
+
+    @Bean
+    public XxlMqSpringClientFactory getXxlMqConsumer(){
+
+        XxlMqSpringClientFactory xxlMqSpringClientFactory = new XxlMqSpringClientFactory();
+        xxlMqSpringClientFactory.setAdminAddress(adminAddress);
+        xxlMqSpringClientFactory.setAccessToken(accessToken);
+
+        return xxlMqSpringClientFactory;
+    }
+
+}

+ 12 - 0
src/main/resources/application.properties

@@ -0,0 +1,12 @@
+### web
+server.port=8082
+server.context-path=/
+
+### resources
+spring.mvc.static-path-pattern=/static/**
+spring.resources.static-locations=classpath:/static/
+
+# xxl-mq, admin conf
+xxl.mq.admin.address=http://localhost:8080/xxl-mq-admin
+### xxl-mq, access token
+xxl.mq.accessToken=

+ 12 - 0
target/classes/application.properties

@@ -0,0 +1,12 @@
+### web
+server.port=8082
+server.context-path=/
+
+### resources
+spring.mvc.static-path-pattern=/static/**
+spring.resources.static-locations=classpath:/static/
+
+# xxl-mq, admin conf
+xxl.mq.admin.address=http://localhost:8080/xxl-mq-admin
+### xxl-mq, access token
+xxl.mq.accessToken=

BIN
target/classes/cn/com/ctop/bytedance/MainApplication.class


BIN
target/classes/cn/com/ctop/bytedance/comsumer/BytednaceAuthComsumer.class


BIN
target/classes/cn/com/ctop/bytedance/conf/XxlMqConf.class