单机版

application.yml

主配置文件

  1. #工程访问配置
  2. server:
  3. port: 8081
  4. servlet:
  5. context-path: /gc-starter-uc-server
  6. #spring环境配置
  7. spring:
  8. profiles:
  9. # 运行环境 dev|test|prod,根据active动态加载application-active.yml配置文件
  10. # 切换数据库时,注意下面的-xxx 也修改为对应的数据库(mysql、oracle、pg)
  11. active: dev
  12. include: base,druid-mysql,mybatis-plus-mysql,cas
  13. # mybatis
  14. mybatis-plus:
  15. # 实体扫描,多个package用逗号或者分号分隔
  16. typeAliasesPackage: com.gccloud.starter.*.entity,com.gccloud.gc.starter.uc.common.entity

application-${spring.profiles.active}.yml

激活的其他文件
application-prod

spring:
  servlet:
    multipart:
      # 配置上传下载文件的最大值
      max-file-size: 500MB
      max-request-size: 500MB
  resources:
    static-locations: classpath:/static/,classpath:/META-INF/resources/,classpath:/META-INF/resources/webjars/,file:${gc.starter.file.basePath},classpath:/saml
  datasource:
    type: com.alibaba.druid.pool.DruidDataSource
    driverClassName: com.p6spy.engine.spy.P6SpyDriver
    url: jdbc:p6spy:mysql://192.168.1.1:3306/gc_starter_uc?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
    username: ***
    password: ***

gc:
  starter:
    file:
      # 本地的一个存储文件的绝对路径,需要有写入权限
      basePath: /usr/local/upload
      # 本地启动服务的地址
      urlPrefix: http://192.168.59.117:30032/${server.servlet.context-path}/static/
    shiro:
      filter-chain-definition-map:
        # 开放接口(不登录即可访问)
        '[/xx/**]': anon
        '[/yy/**]': anon
    license:
      # 从2.0.0.RELEASE 版本开始,开发者必须向千行开发团队提供项目基本信息进行License申请,否则后端项目无法启动 详见:http://60.174.249.206:8188/gc-starter-component-lib/lib/qa/startFail.html
      appKey: gc-starter-uc-server
      appSecret: gc-starter-uc-server
    csrf:
      # 是否允许不传入Referer头
      allowedEmpty: true
      # 允许哪些 Referer 可以访问,以所列的url开头表示允许,使用http来允许所有的referer,这是不安全的
      allowedReferers:
        - http
    cache:
      redis:
        # 模式 STANDALONE(单机)、SENTINEL(哨兵) 暂不支持集群
        mode: STANDALONE
        host: 192.168.59.1
        port: 6379
        password: ''
        database: 0
        # 操作超时时间,单位毫秒,默认2秒
        soTimeout: 2000
        # 连接超时时间,单位毫秒,默认2秒
        connectionTimeout: 2000
        # 哨兵配置
        sentinel:
          master: master
          # 接入机地址列表,多个之间使用逗号隔开,格式如: ip1:port1,ip2:port2
          nodes: host1:port1,host2:port2
        # 连接池配置
        pool:
          # 连接池最大阻塞等待时间(使用负值表示没有限制)
          max-wait: 60000
          # 最大连接数(空闲+使用中),不超过应用线程数,建议为应用线程数的一半,默认8
          maxTotal: 20
          # 最大空闲连接数,不超过最大连接数,默认8
          max-idle: 10
          # 最小空闲连接个数
          min-idle: 5
          # 获取连接时的最大等待毫秒数,如果超时就抛异常, 小于零:阻塞不确定的时间, 默认-1
          maxWaitMillis: 60000
          testOnBorrow: false
          testOnReturn: true
          # 在空闲时检查有效性,默认true
          testWhileIdle: true
    jwt:
      # 存储到Redis中
      store-strategy: dis
    component:
        # 禁用xss
      XssWhitelist: disable
      XssEscapeFilter: disable
      # 重写框架中根据appKey获取appSecret方法
      ISysAppService: UcSysAppServiceImpl
uc:
  ac:
    # 认证中心地址
    prefixUrl: http://192.168.59.117:30030/gc-starter-ac/service
    authn:
      # 保持和认证中心的一致
      appKey: zREjZx9tT1eg5bPkSMsrqp03HLo9Mtad
      # 保持和认证中心的一致
      appSecret: 4ua4uQggI0g5DRIxc3oP5hDElUX8TcYW

# 用户中心作为CAS协议客户端集成到用户中心
cas:
  # 认证中心服务信息->服务URL
  serverUrlPrefix: http://192.168.59.117:30030/gc-starter-ac
  # 认证中心服务信息->登录URL
  serverLoginUrl: http://192.168.59.117:30030/gc-starter-ac/login
  # 应用服务URL
  service: http://192.168.59.117:30032/gc-starter-uc-server/cas/login
  # 认证成功后,需要跳转的页面地址
  uiUrl: http://192.168.59.117:30033/gc-starter-uc-ui/#

微服务版

bootstrap.yml

# 统一变量设置
uc:
  nacos:
    # nacos 服务地址,集群使用逗号隔开
    server-addr: 192.168.1.1:8848
    # 使用的命名空间ID,非名称
    namespace: uc
    # 使用的组
    group: uc_dev_group
spring:
  application:
    # 注册到nacos上的服务名
    name: uc
  cloud:
    nacos:
      config:
        file-extension: yaml
        server-addr: ${uc.nacos.server-addr}
        namespace: ${uc.nacos.namespace}
        group: ${uc.nacos.group}
        # 共享配置文件,如果需要inclue 多个配置文件,可以在下面继续添加
        shared-configs:
          - data-id: data-source.yaml
            group: ${uc.nacos.group}
            refresh: true
          - data-id: application-base.yaml
            group: ${uc.nacos.group}
            refresh: true
          - data-id: application-druid-mysql.yaml
            group: ${uc.nacos.group}
            refresh: true
          - data-id: application-mybatis-plus-mysql.yaml
            group: ${uc.nacos.group}
            refresh: true
      discovery:
        server-addr: ${uc.nacos.server-addr}
        namespace: ${uc.nacos.namespace}
        group: ${uc.nacos.group}

data-source.yaml

spring:
  datasource:
    type: com.alibaba.druid.pool.DruidDataSource
    driverClassName: com.p6spy.engine.spy.P6SpyDriver
    url: jdbc:p6spy:mysql://192.168.9.1:3306/xxx?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
    username: xxx
    password: xxx
  • shared-configs中的 application-base.yaml 、application-druid-mysql.yaml、application-mybatis-plus-mysql.yaml 配置文件在引用的 gc-starter-common/resources中,找到对应配置文件(可参考千行配置文件)添加到nacos中。
  • 在nacos中添加配置时,一定要以.yaml结尾,非 .yml 结尾
  • data-source.yaml 为配置数据库

    messages_zh_CN.properties

    国际化配置
    gc.starter.module.name=应用