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
44822319
Commit
44822319
authored
Apr 02, 2019
by
陈文顺
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
apollo
parent
c78812d4
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
122 additions
and
64 deletions
+122
-64
springboot-demo/src/main/java/com/freemud/springbootdemo/SpringbootDemoApplication.java
+2
-0
springboot-demo/src/main/java/com/freemud/springbootdemo/config/DataSourceConfig.java
+7
-0
springboot-demo/src/main/java/com/freemud/springbootdemo/config/Swagger2.java
+22
-1
springboot-demo/src/main/resources/application.yml
+63
-63
springboot-demo/src/main/resources/logback-test.xml
+28
-0
No files found.
springboot-demo/src/main/java/com/freemud/springbootdemo/SpringbootDemoApplication.java
View file @
44822319
package
com
.
freemud
.
springbootdemo
;
import
com.alibaba.fastjson.support.spring.FastJsonpHttpMessageConverter4
;
import
com.ctrip.framework.apollo.spring.annotation.EnableApolloConfig
;
import
org.mybatis.spring.annotation.MapperScan
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
...
...
@@ -15,6 +16,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
@ComponentScan
(
basePackages
=
"com.freemud, cn.freemud"
)
@MapperScan
(
basePackages
=
"com.freemud.demo.mapper"
)
//@EnableEurekaClient
@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 @
44822319
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
;
...
...
@@ -26,6 +28,11 @@ import java.util.stream.Collectors;
@Configuration
public
class
DataSourceConfig
{
@ApolloConfig
private
Config
config
;
@Bean
@Primary
@ConfigurationProperties
(
prefix
=
"datasource.druid"
)
...
...
springboot-demo/src/main/java/com/freemud/springbootdemo/config/Swagger2.java
View file @
44822319
package
com
.
freemud
.
springbootdemo
.
config
;
import
com.ctrip.framework.apollo.model.ConfigChangeEvent
;
import
com.ctrip.framework.apollo.spring.annotation.ApolloConfigChangeListener
;
import
org.springframework.beans.BeansException
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.cloud.context.environment.EnvironmentChangeEvent
;
import
org.springframework.cloud.context.refresh.ContextRefresher
;
import
org.springframework.cloud.context.scope.refresh.RefreshScope
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.ApplicationContextAware
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
springfox.documentation.builders.ApiInfoBuilder
;
...
...
@@ -25,11 +33,19 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
*/
@Configuration
@EnableSwagger2
public
class
Swagger2
{
public
class
Swagger2
implements
ApplicationContextAware
{
private
ApplicationContext
applicationContext
;
@Value
(
"${swagger_enable:}"
)
String
swaggerEnable
;
@ApolloConfigChangeListener
public
void
onChange
(
ConfigChangeEvent
changeEvent
){
System
.
out
.
println
(
changeEvent
.
changedKeys
());
}
@Bean
public
Docket
createRestApi
()
{
return
new
Docket
(
DocumentationType
.
SWAGGER_2
)
...
...
@@ -48,4 +64,9 @@ public class Swagger2 {
.
version
(
"1.0"
)
.
build
();
}
@Override
public
void
setApplicationContext
(
ApplicationContext
applicationContext
)
throws
BeansException
{
this
.
applicationContext
=
applicationContext
;
}
}
springboot-demo/src/main/resources/application.yml
View file @
44822319
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
#log
#
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
...
...
@@ -67,19 +67,19 @@ logging:
# password: admin
# ignored: /**,/swagger*,/webjars/**,/v2/**,/swagger-resources/**
swagger_enable
:
true
#
swagger_enable: true
#eureka:
# client:
# service-url:
# defaultZone: http://localhost:10001/eureka
#
apollo:
#
bootstrap:
#
enabled: true
#
meta: http://localhost:8080
apollo
:
bootstrap
:
enabled
:
true
meta
:
http://localhost:8080
#apollo appId
#
app:
#
id: order_service
app
:
id
:
order_service
springboot-demo/src/main/resources/logback-test.xml
0 → 100644
View file @
44822319
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<springProperty
scope=
"context"
name=
"springAppName"
source=
"spring.application.name"
/>
<!-- %m输出的信息,%p日志级别,%t线程名,%d日期,%c类的全名,,,, -->
<appender
name=
"STDOUT"
class=
"ch.qos.logback.core.ConsoleAppender"
>
<encoder>
<charset>
UTF-8
</charset>
<pattern>
%d %p (%file:%line\)- %m%n
</pattern>
</encoder>
</appender>
<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 >
</layout >
</appender >
<root
level=
"info"
>
<appender-ref
ref=
"STDOUT_tid"
/>
</root>
</configuration>
\ No newline at end of file
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