Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dict
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
陈文顺
dict
Commits
b80e53fd
Commit
b80e53fd
authored
Jul 03, 2019
by
陈文顺
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
spring 升级
parent
44822319
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
128 additions
and
84 deletions
+128
-84
demo-service/pom.xml
+1
-1
pom.xml
+27
-7
springboot-demo/pom.xml
+20
-1
springboot-demo/src/main/java/com/freemud/springbootdemo/SpringbootDemoApplication.java
+1
-1
springboot-demo/src/main/java/com/freemud/springbootdemo/config/DataSourceConfig.java
+8
-13
springboot-demo/src/main/java/com/freemud/springbootdemo/config/Swagger2.java
+11
-2
springboot-demo/src/main/resources/application.yml
+57
-57
springboot-demo/src/main/resources/logback-test.xml
+2
-1
springboot-demo/src/main/resources/logback.xml
+1
-1
No files found.
demo-service/pom.xml
View file @
b80e53fd
...
...
@@ -58,7 +58,7 @@
<dependency>
<groupId>
com.github.pagehelper
</groupId>
<artifactId>
pagehelper-spring-boot-starter
</artifactId>
<version>
${mapper.version}
</version>
<version>
1.2.5
</version>
</dependency>
</dependencies>
...
...
pom.xml
View file @
b80e53fd
...
...
@@ -4,12 +4,12 @@
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>
1.5.10.RELEASE
</version
>
<
relativePath/>
<!-- lookup parent from repository
-->
<
/parent
>
<
!--<parent>--
>
<
!--<groupId>org.springframework.boot</groupId>--
>
<
!--<artifactId>spring-boot-starter-parent</artifactId>--
>
<
!--<version>1.5.10.RELEASE</version>--
>
<
!--<relativePath/> <!– lookup parent from repository –>
-->
<
!--</parent>--
>
<groupId>
com.freemud.demo
</groupId>
<artifactId>
spring-demo-parent
</artifactId>
...
...
@@ -27,16 +27,36 @@
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<project.reporting.outputEncoding>
UTF-8
</project.reporting.outputEncoding>
<java.version>
1.8
</java.version>
<spring-cloud.version>
Edgware.SR2
</spring-cloud.version>
<spring.boot.version>
2.1.4.RELEASE
</spring.boot.version>
<spring-cloud.version>
Greenwich.SR1
</spring-cloud.version>
<mybatis3.version>
1.3.2
</mybatis3.version>
<mapper.version>
1.1.1
</mapper.version>
<elasticSearch.version>
3.1.5.RELEASE
</elasticSearch.version>
<maven.compiler.source>
${java.version}
</maven.compiler.source>
<maven.compiler.target>
${java.version}
</maven.compiler.target>
<mysql.version>
5.1.43
</mysql.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-dependencies
</artifactId>
<version>
${spring.boot.version}
</version>
<type>
pom
</type>
<scope>
import
</scope>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-dependencies
</artifactId>
<version>
${spring-cloud.version}
</version>
<type>
pom
</type>
<scope>
import
</scope>
</dependency>
<dependency>
<groupId>
io.springfox
</groupId>
<artifactId>
springfox-swagger2
</artifactId>
<version>
2.7.0
</version>
...
...
springboot-demo/pom.xml
View file @
b80e53fd
...
...
@@ -67,9 +67,20 @@
<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>-->
<!--</exclusions>-->
</dependency>
<!--<dependency>-->
<!--<groupId>org.springframework.boot</groupId>-->
<!--<artifactId>spring-boot-starter-jetty</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.springframework.data</groupId>-->
<!--<artifactId>spring-data-elasticsearch</artifactId>-->
<!--</dependency>-->
...
...
@@ -135,7 +146,7 @@
<dependency>
<groupId>
com.ctrip.framework.apollo
</groupId>
<artifactId>
apollo-client
</artifactId>
<version>
1.
1
.0
</version>
<version>
1.
4
.0
</version>
</dependency>
<dependency>
...
...
@@ -152,6 +163,14 @@
<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>
...
...
springboot-demo/src/main/java/com/freemud/springbootdemo/SpringbootDemoApplication.java
View file @
b80e53fd
...
...
@@ -16,7 +16,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
@ComponentScan
(
basePackages
=
"com.freemud, cn.freemud"
)
@MapperScan
(
basePackages
=
"com.freemud.demo.mapper"
)
//@EnableEurekaClient
@EnableApolloConfig
//
@EnableApolloConfig
public
class
SpringbootDemoApplication
extends
WebMvcConfigurerAdapter
{
public
static
void
main
(
String
[]
args
)
{
...
...
springboot-demo/src/main/java/com/freemud/springbootdemo/config/DataSourceConfig.java
View file @
b80e53fd
...
...
@@ -3,24 +3,17 @@ package com.freemud.springbootdemo.config;
import
com.alibaba.druid.pool.DruidDataSource
;
import
com.ctrip.framework.apollo.Config
;
import
com.ctrip.framework.apollo.spring.annotation.ApolloConfig
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder
;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.boot.jdbc.DataSourceBuilder
;
import
org.springframework.cloud.context.config.annotation.RefreshScope
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Primary
;
import
org.springframework.core.io.Resource
;
import
javax.sql.DataSource
;
import
java.io.BufferedReader
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.util.HashMap
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
/**
* Created by chenwenshun on 2018/8/31.
...
...
@@ -28,13 +21,15 @@ import java.util.stream.Collectors;
@Configuration
public
class
DataSourceConfig
{
private
ApplicationContext
applicationContext
;
@ApolloConfig
private
Config
config
;
@Bean
@Primary
@RefreshScope
@ConfigurationProperties
(
prefix
=
"datasource.druid"
)
public
DataSource
dataSource_0
(){
return
DataSourceBuilder
.
create
()
...
...
springboot-demo/src/main/java/com/freemud/springbootdemo/config/Swagger2.java
View file @
b80e53fd
...
...
@@ -2,8 +2,10 @@ package com.freemud.springbootdemo.config;
import
com.ctrip.framework.apollo.model.ConfigChangeEvent
;
import
com.ctrip.framework.apollo.spring.annotation.ApolloConfigChangeListener
;
import
com.ctrip.framework.apollo.spring.annotation.EnableApolloConfig
;
import
org.springframework.beans.BeansException
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.cloud.context.environment.EnvironmentChangeEvent
;
import
org.springframework.cloud.context.refresh.ContextRefresher
;
import
org.springframework.cloud.context.scope.refresh.RefreshScope
;
...
...
@@ -11,6 +13,7 @@ import org.springframework.context.ApplicationContext;
import
org.springframework.context.ApplicationContextAware
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Scope
;
import
springfox.documentation.builders.ApiInfoBuilder
;
import
springfox.documentation.builders.PathSelectors
;
import
springfox.documentation.builders.RequestHandlerSelectors
;
...
...
@@ -35,17 +38,23 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
@EnableSwagger2
public
class
Swagger2
implements
ApplicationContextAware
{
private
final
RefreshScope
refreshScope
;
private
ApplicationContext
applicationContext
;
@Value
(
"${swagger_enable:}"
)
String
swaggerEnable
;
@ApolloConfigChangeListener
public
Swagger2
(
RefreshScope
refreshScope
)
{
this
.
refreshScope
=
refreshScope
;
}
@ApolloConfigChangeListener
(
interestedKeys
=
{
"swagger_enable"
})
public
void
onChange
(
ConfigChangeEvent
changeEvent
){
System
.
out
.
println
(
changeEvent
.
changedKeys
());
}
@Bean
public
Docket
createRestApi
()
{
return
new
Docket
(
DocumentationType
.
SWAGGER_2
)
...
...
springboot-demo/src/main/resources/application.yml
View file @
b80e53fd
spring
:
application
:
name
:
dictionary
#
redis:
#
#
host: 10.20.10.212
#
host: 115.159.67.166
#
port: 5289
#
password: U252fnIDyfF1A1
#
database: 3
#
datasource:
#
initialize: false
#
server:
#
port: 9005
#
datasource:
#
druid:
#
url: jdbc:mysql://111.231.82.13:6630/dict?useUnicode=true&characterEncoding=utf8
#
driver-class: com.mysql.jdbc.Driver
#
username: yanfa
#
password: yqKjKHX.1:bv
#
initial-size: 1
#
min-idle: 1
#
max-active: 20
#
test-on-borrow: true
#
filters: stat
#
#
datasource2:
#
druid:
#
url: jdbc:mysql://111.231.82.13:6630/dict2?useUnicode=true&characterEncoding=utf8
#
driver-class: com.mysql.jdbc.Driver
#
username: yanfa
#
password: yqKjKHX.1:bv
#
initial-size: 1
#
min-idle: 1
#
max-active: 20
#
test-on-borrow: true
#
filters: stat
#
#
#
#
mybatis
#
mybatis:
#
config-location: classpath:mybatis.xml
#
mapper-locations: classpath:mapper/*.xml
#
type-aliases-package: com.freemud.demo.model
#
#
#
dao
#
mapper:
#
mappers: com.freemud.demo.util.MyMapper
#
not-empty: false
#
identity: MYSQL
#
#
before: true
#
#
#
pagehelper
#
pagehelper:
#
helper-dialect: mysql
#
reasonable: true
#
support-methods-arguments: true
#
params: count=countSql
redis
:
# host: 10.20.10.212
host
:
115.159.67.166
port
:
5289
password
:
U252fnIDyfF1A1
database
:
3
datasource
:
initialize
:
false
server
:
port
:
9005
datasource
:
druid
:
url
:
jdbc:mysql://111.231.82.13:6630/dict?useUnicode=true&characterEncoding=utf8
driver-class
:
com.mysql.jdbc.Driver
username
:
yanfa
password
:
yqKjKHX.1:bv
initial-size
:
1
min-idle
:
1
max-active
:
20
test-on-borrow
:
true
filters
:
stat
datasource2
:
druid
:
url
:
jdbc:mysql://111.231.82.13:6630/dict2?useUnicode=true&characterEncoding=utf8
driver-class
:
com.mysql.jdbc.Driver
username
:
yanfa
password
:
yqKjKHX.1:bv
initial-size
:
1
min-idle
:
1
max-active
:
20
test-on-borrow
:
true
filters
:
stat
#mybatis
mybatis
:
config-location
:
classpath:mybatis.xml
mapper-locations
:
classpath:mapper/*.xml
type-aliases-package
:
com.freemud.demo.model
#dao
mapper
:
mappers
:
com.freemud.demo.util.MyMapper
not-empty
:
false
identity
:
MYSQL
# before: true
#pagehelper
pagehelper
:
helper-dialect
:
mysql
reasonable
:
true
support-methods-arguments
:
true
params
:
count=countSql
#
##log
logging
:
config
:
classpath:logback.xml
config
:
classpath:logback
-test
.xml
#security:
...
...
@@ -76,10 +76,10 @@ logging:
apollo
:
bootstrap
:
enabled
:
true
meta
:
http://
localhost:8080
meta
:
http://
212.129.229.203
#apollo appId
app
:
id
:
order_service
id
:
dictionary
springboot-demo/src/main/resources/logback-test.xml
View file @
b80e53fd
...
...
@@ -15,7 +15,8 @@
<appender
name =
"STDOUT_tid"
class=
"ch.qos.logback.core.ConsoleAppender"
>
<layout
class =
"ch.qos.logback.classic.PatternLayout"
>
<!--<Pattern >%d{HH:mm} %-5level %logger{36} - [springAppName:${springAppName:-}, TxId : %X{X-B3-TraceId:-} , SpanId : %X{X-B3-SpanId:-}] %msg%n</Pattern >-->
<Pattern
>
%d{HH:mm} %-5level %logger{36} - [${springAppName}] %msg%n
</Pattern >
<!--<Pattern >%d{HH:mm:ss.SSS} %-5level %logger{36} - [${springAppName}] %msg%n</Pattern >-->
<Pattern
>
%date %level [%thread] %logger{10} [%file:%line] - %msg%n
</Pattern >
</layout >
</appender >
...
...
springboot-demo/src/main/resources/logback.xml
View file @
b80e53fd
...
...
@@ -15,7 +15,7 @@
<appender
name =
"STDOUT_tid"
class=
"ch.qos.logback.core.ConsoleAppender"
>
<layout
class =
"ch.qos.logback.classic.PatternLayout"
>
<!--<Pattern >%d{HH:mm} %-5level %logger{36} - [springAppName:${springAppName:-}, TxId : %X{X-B3-TraceId:-} , SpanId : %X{X-B3-SpanId:-}] %msg%n</Pattern >-->
<Pattern
>
%d{HH:mm} %-5level %logger{36} - [spring-demo,%X{X-B3-TraceId:-},%X{X-B3-SpanId:-}] %msg%n
</Pattern >
<Pattern
>
%d{HH:mm
:ss.SSS
} %-5level %logger{36} - [spring-demo,%X{X-B3-TraceId:-},%X{X-B3-SpanId:-}] %msg%n
</Pattern >
</layout >
</appender >
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment