Commit ec7f8a5d7ff1cd06e9e0a90934532f06f72757c1
0 parents
Exists in
master
first
Showing
7 changed files
with
454 additions
and
0 deletions
Show diff stats
1 | +++ a/pom.xml | |
... | ... | @@ -0,0 +1,243 @@ |
1 | +<?xml version="1.0" encoding="UTF-8"?> | |
2 | +<project xmlns="http://maven.apache.org/POM/4.0.0" | |
3 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
4 | + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
5 | + <modelVersion>4.0.0</modelVersion> | |
6 | + <parent> | |
7 | + <groupId>org.springframework.boot</groupId> | |
8 | + <artifactId>spring-boot-starter-parent</artifactId> | |
9 | + <version>2.1.6.RELEASE</version> | |
10 | + </parent> | |
11 | + <groupId>org.example</groupId> | |
12 | + <artifactId>wechatBusiness</artifactId> | |
13 | + <version>1.0-SNAPSHOT</version> | |
14 | + <dependencies> | |
15 | + <!-- <dependency>--> | |
16 | + <!-- <groupId>org.springframework.boot</groupId>--> | |
17 | + <!-- <artifactId>spring-boot-starter-data-redis</artifactId>--> | |
18 | + <!-- <version>2.2.1.RELEASE</version>--> | |
19 | + <!-- </dependency>--> | |
20 | + <!-- <dependency>--> | |
21 | + <!-- <groupId>org.apache.commons</groupId>--> | |
22 | + <!-- <artifactId>commons-pool2</artifactId>--> | |
23 | + <!-- <version>2.4.2</version>--> | |
24 | + <!-- </dependency>--> | |
25 | + <dependency> | |
26 | + <groupId>org.springframework.boot</groupId> | |
27 | + <artifactId>spring-boot-starter-web</artifactId> | |
28 | + </dependency> | |
29 | + <dependency> | |
30 | + <groupId>org.springframework.boot</groupId> | |
31 | + <artifactId>spring-boot-starter-test</artifactId> | |
32 | + <scope>test</scope> | |
33 | + </dependency> | |
34 | + | |
35 | + <dependency> | |
36 | + <groupId>com.aliyun.oss</groupId> | |
37 | + <artifactId>aliyun-sdk-oss</artifactId> | |
38 | + <version>2.8.3</version> | |
39 | + </dependency> | |
40 | + <dependency> | |
41 | + <groupId>org.mybatis.generator</groupId> | |
42 | + <artifactId>mybatis-generator-core</artifactId> | |
43 | + <version>1.3.5</version> | |
44 | + </dependency> | |
45 | + <dependency> | |
46 | + <groupId>org.apache.poi</groupId> | |
47 | + <artifactId>poi</artifactId> | |
48 | + <version>4.1.0</version> | |
49 | + </dependency> | |
50 | + <dependency> | |
51 | + <groupId>org.apache.poi</groupId> | |
52 | + <artifactId>poi-ooxml</artifactId> | |
53 | + <version>4.1.0</version> | |
54 | + </dependency> | |
55 | + <dependency> | |
56 | + <groupId>org.apache.poi</groupId> | |
57 | + <artifactId>poi-scratchpad</artifactId> | |
58 | + <version>4.1.0</version> | |
59 | + </dependency> | |
60 | + <dependency> | |
61 | + <groupId>org.slf4j</groupId> | |
62 | + <artifactId>slf4j-api</artifactId> | |
63 | + <version>1.7.13</version> | |
64 | + </dependency> | |
65 | + <dependency> | |
66 | + <groupId>com.github.pagehelper</groupId> | |
67 | + <artifactId>pagehelper-spring-boot-starter</artifactId> | |
68 | + <version>1.2.12</version> | |
69 | + </dependency> | |
70 | + <dependency> | |
71 | + <groupId>com.alibaba</groupId> | |
72 | + <artifactId>fastjson</artifactId> | |
73 | + <version>1.2.16</version> | |
74 | + </dependency> | |
75 | + <dependency> | |
76 | + <groupId>com.nimbusds</groupId> | |
77 | + <artifactId>nimbus-jose-jwt</artifactId> | |
78 | + <version>6.0</version> | |
79 | + </dependency> | |
80 | + | |
81 | + <dependency> | |
82 | + <groupId>org.apache.commons</groupId> | |
83 | + <artifactId>commons-lang3</artifactId> | |
84 | + <version>3.3.2</version> | |
85 | + </dependency> | |
86 | + <dependency> | |
87 | + <groupId>org.mybatis.spring.boot</groupId> | |
88 | + <artifactId>mybatis-spring-boot-starter</artifactId> | |
89 | + <version>1.3.0</version> | |
90 | + </dependency> | |
91 | + <dependency> | |
92 | + <groupId>com.microsoft.sqlserver</groupId> | |
93 | + <artifactId>mssql-jdbc</artifactId> | |
94 | + <version>6.4.0.jre8</version> | |
95 | + </dependency> | |
96 | + | |
97 | + <dependency> | |
98 | + <groupId>org.apache.commons</groupId> | |
99 | + <artifactId>commons-lang3</artifactId> | |
100 | + <version>3.3.2</version> | |
101 | + </dependency> | |
102 | + <dependency> | |
103 | + <groupId>io.springfox</groupId> | |
104 | + <artifactId>springfox-swagger2</artifactId> | |
105 | + <version>2.6.1</version> | |
106 | + </dependency> | |
107 | + <dependency> | |
108 | + <groupId>io.springfox</groupId> | |
109 | + <artifactId>springfox-swagger-ui</artifactId> | |
110 | + <version>2.6.1</version> | |
111 | + </dependency> | |
112 | + <dependency> | |
113 | + <groupId>org.apache.pulsar</groupId> | |
114 | + <artifactId>pulsar-client</artifactId> | |
115 | + <version>2.3.2</version> | |
116 | + </dependency> | |
117 | + <dependency> | |
118 | + <groupId>net.lingala.zip4j</groupId> | |
119 | + <artifactId>zip4j</artifactId> | |
120 | + <version>1.3.2</version> | |
121 | + </dependency> | |
122 | + <dependency> | |
123 | + <groupId>org.springframework</groupId> | |
124 | + <artifactId>spring-test</artifactId> | |
125 | + <version>5.1.9.RELEASE</version> | |
126 | + <scope>compile</scope> | |
127 | + </dependency> | |
128 | + <dependency> | |
129 | + <groupId>org.apache.httpcomponents</groupId> | |
130 | + <artifactId>httpclient</artifactId> | |
131 | + <version>4.5</version> | |
132 | + </dependency> | |
133 | + | |
134 | + <dependency> | |
135 | + <groupId>org.apache.httpcomponents</groupId> | |
136 | + <artifactId>httpmime</artifactId> | |
137 | + <version>4.5</version> | |
138 | + </dependency> | |
139 | + <dependency> | |
140 | + <groupId>dom4j</groupId> | |
141 | + <artifactId>dom4j</artifactId> | |
142 | + <version>1.6.1</version> | |
143 | + </dependency> | |
144 | + </dependencies> | |
145 | + | |
146 | + <build> | |
147 | + <!--打包文件名--> | |
148 | + <finalName>wechatBusiness</finalName> | |
149 | + <!--打包方式--> | |
150 | + <plugins> | |
151 | + | |
152 | + | |
153 | + <plugin> | |
154 | + <groupId>org.mybatis.generator</groupId> | |
155 | + <artifactId>mybatis-generator-maven-plugin</artifactId> | |
156 | + <version>1.3.5</version> | |
157 | + <configuration> | |
158 | + <verbose>true</verbose> | |
159 | + <overwrite>true</overwrite> | |
160 | + </configuration> | |
161 | + </plugin> | |
162 | + | |
163 | + <!-- 设置编译版本 --> | |
164 | + <plugin> | |
165 | + <groupId>org.apache.maven.plugins</groupId> | |
166 | + <artifactId>maven-compiler-plugin</artifactId> | |
167 | + <version>3.1</version> | |
168 | + <configuration> | |
169 | + <source>1.8</source> | |
170 | + <target>1.8</target> | |
171 | + <encoding>UTF-8</encoding> | |
172 | + </configuration> | |
173 | + </plugin> | |
174 | + <!-- 打包jar文件时,配置manifest文件,加入lib包的jar依赖 --> | |
175 | + <!-- 本地启动需要注释--> | |
176 | + <plugin> | |
177 | + <groupId>org.apache.maven.plugins</groupId> | |
178 | + <artifactId>maven-jar-plugin</artifactId> | |
179 | + <configuration> | |
180 | + <archive> | |
181 | + <manifest> | |
182 | + <mainClass>com.sincere.report.StudentApplication</mainClass> | |
183 | + <addClasspath>true</addClasspath> | |
184 | + <classpathPrefix>lib/</classpathPrefix> | |
185 | + </manifest> | |
186 | + <manifestEntries> | |
187 | + <Class-Path>./config/</Class-Path> | |
188 | + </manifestEntries> | |
189 | + </archive> | |
190 | + <excludes> | |
191 | + <exclude>config/**</exclude> | |
192 | + </excludes> | |
193 | + <classesDirectory></classesDirectory> | |
194 | + </configuration> | |
195 | + </plugin> | |
196 | + <!-- 拷贝依赖的jar包到lib目录 --> | |
197 | + <plugin> | |
198 | + <groupId>org.apache.maven.plugins</groupId> | |
199 | + <artifactId>maven-dependency-plugin</artifactId> | |
200 | + <executions> | |
201 | + <execution> | |
202 | + <id>copy</id> | |
203 | + <phase>package</phase> | |
204 | + <goals> | |
205 | + <goal>copy-dependencies</goal> | |
206 | + </goals> | |
207 | + <configuration> | |
208 | + <outputDirectory> | |
209 | + ${project.build.directory}/lib | |
210 | + </outputDirectory> | |
211 | + </configuration> | |
212 | + </execution> | |
213 | + </executions> | |
214 | + </plugin> | |
215 | + <!-- 解决资源文件的编码问题 --> | |
216 | + <plugin> | |
217 | + <groupId>org.apache.maven.plugins</groupId> | |
218 | + <artifactId>maven-resources-plugin</artifactId> | |
219 | + <version>2.5</version> | |
220 | + <configuration> | |
221 | + <encoding>UTF-8</encoding> | |
222 | + </configuration> | |
223 | + </plugin> | |
224 | + <!-- 打包source文件为jar文件 --> | |
225 | + <plugin> | |
226 | + <artifactId>maven-source-plugin</artifactId> | |
227 | + <version>2.2</version> | |
228 | + <configuration> | |
229 | + <attach>true</attach> | |
230 | + </configuration> | |
231 | + <executions> | |
232 | + <execution> | |
233 | + <phase>compile</phase> | |
234 | + <goals> | |
235 | + <goal>jar</goal> | |
236 | + </goals> | |
237 | + </execution> | |
238 | + </executions> | |
239 | + </plugin> | |
240 | + </plugins> | |
241 | + </build> | |
242 | + | |
243 | +</project> | |
0 | 244 | \ No newline at end of file | ... | ... |
1 | +++ a/src/main/java/com/sincere/wechatbusiness/Swagger2.java | |
... | ... | @@ -0,0 +1,50 @@ |
1 | +package com.sincere.wechatbusiness; | |
2 | + | |
3 | +import org.springframework.context.annotation.Bean; | |
4 | +import org.springframework.context.annotation.Configuration; | |
5 | +import springfox.documentation.builders.ApiInfoBuilder; | |
6 | +import springfox.documentation.builders.ParameterBuilder; | |
7 | +import springfox.documentation.builders.PathSelectors; | |
8 | +import springfox.documentation.builders.RequestHandlerSelectors; | |
9 | +import springfox.documentation.schema.ModelRef; | |
10 | +import springfox.documentation.service.ApiInfo; | |
11 | +import springfox.documentation.service.Parameter; | |
12 | +import springfox.documentation.spi.DocumentationType; | |
13 | +import springfox.documentation.spring.web.plugins.Docket; | |
14 | +import springfox.documentation.swagger2.annotations.EnableSwagger2; | |
15 | + | |
16 | +import java.util.ArrayList; | |
17 | +import java.util.List; | |
18 | + | |
19 | +@EnableSwagger2 | |
20 | +@Configuration //让Spring来加载该类配置 | |
21 | +public class Swagger2 { | |
22 | + | |
23 | + @Bean | |
24 | + public Docket createRestApi() { | |
25 | + ParameterBuilder ticketPar = new ParameterBuilder(); | |
26 | + List<Parameter> pars = new ArrayList<Parameter>(); | |
27 | + ticketPar.name("X-Authorization").description("user token") | |
28 | + .modelRef(new ModelRef("string")).parameterType("header") | |
29 | + .required(false).build(); //header中的ticket参数非必填,传空也可以 | |
30 | + pars.add(ticketPar.build()); | |
31 | + | |
32 | + | |
33 | + return new Docket(DocumentationType.SWAGGER_2) | |
34 | + .apiInfo(apiInfo()) | |
35 | + .select() | |
36 | + // 扫描所有有注解的api,用这种方式更灵活 | |
37 | + .apis(RequestHandlerSelectors.basePackage("com.sincere.wechatbusiness.controller")) | |
38 | + .paths(PathSelectors.any()) | |
39 | + .build().globalOperationParameters(pars); | |
40 | + | |
41 | + } | |
42 | + private ApiInfo apiInfo() { | |
43 | + return new ApiInfoBuilder() | |
44 | + .title("Spring Boot中使用Swagger2构建RESTful APIs") | |
45 | + .description("接口文档") | |
46 | + .termsOfServiceUrl("") | |
47 | + .version("1.0") | |
48 | + .build(); | |
49 | + } | |
50 | +} | ... | ... |
src/main/java/com/sincere/wechatbusiness/WechatBusinessApplication.java
0 → 100644
1 | +++ a/src/main/java/com/sincere/wechatbusiness/WechatBusinessApplication.java | |
... | ... | @@ -0,0 +1,17 @@ |
1 | +package com.sincere.wechatbusiness; | |
2 | + | |
3 | +import org.mybatis.spring.annotation.MapperScan; | |
4 | +import org.springframework.boot.SpringApplication; | |
5 | +import org.springframework.boot.autoconfigure.SpringBootApplication; | |
6 | +import org.springframework.cache.annotation.EnableCaching; | |
7 | + | |
8 | +@EnableCaching | |
9 | +@SpringBootApplication | |
10 | +@MapperScan("com.sincere.report.mapper") | |
11 | +public class WechatBusinessApplication { | |
12 | + | |
13 | + public static void main(String[] args) { | |
14 | + SpringApplication.run(WechatBusinessApplication.class, args); | |
15 | + } | |
16 | + | |
17 | +} | ... | ... |
1 | +++ a/src/main/resources/application.yaml | |
... | ... | @@ -0,0 +1,33 @@ |
1 | +server: | |
2 | + port: 9903 | |
3 | +spring: | |
4 | + application: | |
5 | + name: wechatBusiness | |
6 | + datasource: | |
7 | + username: SZJXTUSER | |
8 | + password: xst200919 | |
9 | + url: jdbc:sqlserver://60.190.202.57:14333;database=wechatbusiness | |
10 | + driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver | |
11 | + | |
12 | + jackson: | |
13 | + date-format: yyyy-MM-dd HH:mm:ss | |
14 | + time-zone: GMT+8 | |
15 | + | |
16 | +# cache: | |
17 | +# type: redis | |
18 | +# redis: | |
19 | +# host: 127.0.0.1 | |
20 | +# port: 6379 | |
21 | +# password: | |
22 | +# lettuce: | |
23 | +# pool: | |
24 | +# max-active: 8 | |
25 | +# database: 0 | |
26 | +##mybatis | |
27 | +mybatis: | |
28 | + mapper-locations: classpath:mapper/*.xml | |
29 | + type-aliases-package: com.sincere.report.model | |
30 | + | |
31 | +logging: | |
32 | + level: | |
33 | + com.sincere.report.mapper: debug | |
0 | 34 | \ No newline at end of file | ... | ... |
1 | +++ a/src/main/resources/generatorConfig.xml | |
... | ... | @@ -0,0 +1,48 @@ |
1 | +<?xml version="1.0" encoding="UTF-8"?> | |
2 | +<!DOCTYPE generatorConfiguration | |
3 | + PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN" | |
4 | + "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd"> | |
5 | +<generatorConfiguration> | |
6 | + <classPathEntry location="C://root//sqljdbc4-4.0.jar" /> | |
7 | + | |
8 | + <context targetRuntime="MyBatis3" id="a"> | |
9 | + | |
10 | + <!--<commentGenerator> | |
11 | + <!– 去除自动生成的注释 –> | |
12 | + <property name="suppressAllComments" value="true" /> | |
13 | + </commentGenerator>--> | |
14 | + <!-- 是否生成注释 去除自动生成的注释--> | |
15 | + <commentGenerator> | |
16 | + <property name="suppressDate" value="true"/> | |
17 | + | |
18 | + <property name="suppressAllComments" value="true"/> | |
19 | + </commentGenerator> | |
20 | + <!-- 数据库连接配置 --> | |
21 | + <jdbcConnection driverClass="com.microsoft.sqlserver.jdbc.SQLServerDriver" | |
22 | + connectionURL="jdbc:sqlserver://60.190.202.57:14333;database=report_voluntary" | |
23 | + userId="SZJXTUSER" | |
24 | + password="xst200919" /> | |
25 | + | |
26 | + <!-- 非必需,类型处理器,在数据库类型和java类型之间的转换控制--> | |
27 | + <javaTypeResolver> | |
28 | + <property name="forceBigDecimals" value="false"/> | |
29 | + </javaTypeResolver> | |
30 | + | |
31 | + <!--配置生成的实体包 | |
32 | + targetPackage:生成的实体包位置,默认存放在src目录下 | |
33 | + targetProject:目标工程名 | |
34 | + --> | |
35 | + <javaModelGenerator targetPackage="com.sincere.report.model" targetProject="src/main/java" /> | |
36 | + | |
37 | + <!-- 实体包对应映射文件位置及名称,默认存放在src目录下 --> | |
38 | + <sqlMapGenerator targetPackage="mapper" targetProject="src/main/resources" /> | |
39 | + <!--生成Dao类存放位置--> | |
40 | + <javaClientGenerator type="XMLMAPPER" targetPackage="com.sincere.report.mapper" targetProject="src/main/java"> | |
41 | + <property name="enableSubPackages" value="true"/> | |
42 | + </javaClientGenerator> | |
43 | + <!--生成对应表及类名--> | |
44 | + <table tableName="university_major_rank" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" enableSelectByPrimaryKey="true" | |
45 | + enableUpdateByPrimaryKey="true" | |
46 | + enableDeleteByPrimaryKey="true"></table> | |
47 | + </context> | |
48 | +</generatorConfiguration> | |
0 | 49 | \ No newline at end of file | ... | ... |
1 | +++ a/src/main/resources/logback.xml | |
... | ... | @@ -0,0 +1,60 @@ |
1 | +<?xml version="1.0" encoding="UTF-8"?> | |
2 | +<configuration debug="true"> | |
3 | + <!-- 项目名称 --> | |
4 | + <property name="PROJECT_NAME" value="student" /> | |
5 | + | |
6 | + <!--定义日志文件的存储地址 勿在 LogBack 的配置中使用相对路径--> | |
7 | + <property name="LOG_HOME" value="C://log"/> | |
8 | + | |
9 | + <!-- 控制台输出 --> | |
10 | + <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> | |
11 | + <!--<withJansi>true</withJansi>--> | |
12 | + <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> | |
13 | + <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符--> | |
14 | + <pattern>[%d{yyyy-MM-dd HH:mm:ss.SSS}] [%thread] %highlight([%-5level] %logger{50} - %msg%n)</pattern> | |
15 | + <charset>UTF-8</charset> | |
16 | + </encoder> | |
17 | + </appender> | |
18 | + | |
19 | + <!-- 按照每天生成日志文件 --> | |
20 | + <appender name="SYSTEM_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> | |
21 | + <!-- 过滤器,只打印ERROR级别的日志 --> | |
22 | + <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> | |
23 | + <!--日志文件输出的文件名--> | |
24 | + <FileNamePattern>${LOG_HOME}/${PROJECT_NAME}/%d{yyyy-MM-dd HH}.%i.log</FileNamePattern> | |
25 | + <!--日志文件保留天数--> | |
26 | + <MaxHistory>30</MaxHistory> | |
27 | + <!--日志文件最大的大小--> | |
28 | + <MaxFileSize>100MB</MaxFileSize> | |
29 | + </rollingPolicy> | |
30 | + | |
31 | + <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> | |
32 | + <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符--> | |
33 | + <pattern>[%d{yyyy-MM-dd HH:mm:ss.SSS}] [%thread] [%-5level] %logger{50} - %msg%n</pattern> | |
34 | + <charset>UTF-8</charset> | |
35 | + </encoder> | |
36 | + </appender> | |
37 | + <logger name="system_error" additivity="true"> | |
38 | + <appender-ref ref="SYSTEM_FILE"/> | |
39 | + </logger> | |
40 | + | |
41 | + <!-- 设置Spring&Hibernate日志输出级别 --> | |
42 | + <logger name="org.springframework" level="WARN" /> | |
43 | + <logger name="org.mybatis" level="WARN" /> | |
44 | + <logger name="com.ibatis" level="DEBUG" /> | |
45 | + <logger name="com.ibatis.common.jdbc.SimpleDataSource" level="DEBUG" /> | |
46 | + <logger name="com.ibatis.common.jdbc.ScriptRunner" level="DEBUG" /> | |
47 | + <logger name="com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate" level="DEBUG" /> | |
48 | + | |
49 | + | |
50 | + <logger name="java.sql.Connection" level="DEBUG" /> | |
51 | + <logger name="java.sql.Statement" level="DEBUG" /> | |
52 | + <logger name="java.sql.PreparedStatement" level="DEBUG" /> | |
53 | + <logger name="com.sincere.smartSearch.mapper" level="DEBUG" /> | |
54 | + <!-- 开发环境下的日志配置 --> | |
55 | + <root level="ERROR"> | |
56 | + <appender-ref ref="CONSOLE" /> | |
57 | + <appender-ref ref="SYSTEM_FILE" /> | |
58 | + </root> | |
59 | + | |
60 | +</configuration> | ... | ... |