环境配置

# 环境配置

在编译打包 邻邻商城 前,你需要修改配置文件 lln-mall/lln-web/application.ymllln-mall/lln-web/application-xxx.yml 部分配置,以确保你的环境配置正确。

# 基础配置修改

修改 lln-mall/lln-web/application.yml 配置文件

主要修改启动端口
























 







































































#服务器配置
server:
  undertow:
    io-threads: 4
    worker-threads: 20
    buffer-size: 1024
    direct-buffers: true
    max-http-post-size: 20MB
    max-post-size: 20MB
  use-forward-headers: true
  port: 8080

#spring配置
spring:
  profiles:
    active: '@profile.active@'  #pom.xml文件中启用的环境变量
  application:
    name: LLN-MALL
  mvc:
    favicon:
      enabled: false
  jackson:
    date-format: yyyy-MM-dd HH:mm:ss
    time-zone: GMT+8
  servlet:
    multipart:
      #指定上传时的临时目录,解决长时间未使用临时目录被删除的问题
      location: /usr/local/file/data/temp
      max-file-size: 20MB
      max-request-size: 20MB
      enabled: true
      file-size-threshold: 0

  datasource:
    druid:
      type: com.alibaba.druid.pool.DruidDataSource
      driverClassName: ${env.mysql.driver}
      url: ${env.mysql.url}
      username: ${env.mysql.username}
      password: ${env.mysql.password}
      connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000;config.decrypt=true;config.decrypt.key=${env.mysql.publickey}    #数据库密码加密
      filters: stat,config,wall,log4j   # 配置监控统计拦截的filters,去掉后监控界面sql无法统计,'wall'用于防火墙
      initialSize: 10
      minIdle: 10
      #maxIdle: 25
      maxActive: 100
      maxWait: 60000
      maxAge: 600000
      removeAbandoned: true
      removeAbandonedTimeout: 60
      timeBetweenEvictionRunsMillis: 20000
      minEvictableIdleTimeMillis: 300000
      validationQuery: SELECT 1
      validationQueryTimeout: 25
      validationInterval: 30
      testOnBorrow: true
      testWhileIdle: true
      testOnReturn: true
      maxOpenPreparedStatements: 100
      jdbcInterceptors: ConnectionState
      defaultTransactionIsolation: 2
      initSQL: SELECT 1
      logAbandoned: true
      jmxEnabled: true
  cache:
    redis:
      key-prefix:
      time-to-live: 0ms #缓存超时时间戳,配置为0则不设置超时时间 60000ms
      use-key-prefix: true #是否启用Redis的键前缀
    type: redis
    cache-names:
  redis:
    password: ${env.redis.password}
    database: ${env.redis.database}
    timeout: 30000ms #链接超时时长
    jedis:
      pool:
        maxIdle: 20
        minIdle: 5
        maxActive: 30
        maxWait: -1ms
    sentinel:
      master: mymaster
      nodes: ${env.redis.url}

logging.level.org.springframework.boot.autoconfigure: ERROR

management:
security:
    enabled: true

error:
  whitelabel:
    enabled: false
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94

# 修改启动端口




	server:
	  port: 8080
1
2

# 使用tomcat

强烈建议使用undertow服务器

实在要使用tomcat则去除undertow相关配置,并且在pom.xml添加tomcat的相关依赖









  undertow:
    io-threads: 4
    worker-threads: 20
    buffer-size: 1024
    direct-buffers: true
    max-http-post-size: 20MB
    max-post-size: 20MB
1
2
3
4
5
6
7
  <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-tomcat</artifactId>
      <scope>provided</scope>
  </dependency>
1
2
3
4
5

# 修改环境配置

不同的环境回对应一个环境配置文件,如:application-pro.ymlapplication-local.yml

默认情况下会启用lln-mall/lln-web/application-pro.yml环境 配置文件。

如何修改默认启用的配置文件 ,请参考 这里

下面mysql配置中password和publickey是通过druid将密码简单加密产生的,如何加密请参考 这里
























 
















env:
  mysql:
    driver: com.mysql.jdbc.Driver
    url: jdbc:mysql://localhost:3306/lln-mall?characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useUnicode=true&autoReconnect=true&failOverReadOnly=true&loadBalanceStrategy=random&readFormMasterNoSlaves=true
    username: root
    password: druid加密后的密码
    publickey: MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBALLr3kVNc5RP+WSqO0DZmGZVWneTl1AJfj5l3okME4Y/b+zkl2JILus7ByplR65rYpd6e6hn3PDYUkZ0u+4kqskCAwEAAQ==
  redis:
    url: 127.0.0.1:6379
    password:
    database: 8
  es:
    host: localhost
    port: 9200
    scheme: http
	
lln:
  #线程池
  threadPool:
    corePoolSize: 20
    maxPoolSize: 50
    queueCapacity: 50
    keepAliveSeconds: 300

  #邮件配置
  platformEmail:
    host: smtp.exmail.qq.com #即将去除
    account: 地址 #即将去除
    password: 密码 #即将去除

  #请求配置
  appUrl: https://域名 #api请求基础地址
  fileUrl: https://域名 #文件请求基础地址
  scheduleKey: 任务调度接口加密key  #需要同lln-scheduler项目中的key保持一致

  #文件配置
  baseServerFilePath: /usr/local/file/smart-community  #服务器文件基础路径 /home/flower
  realFilePath: /data/        #永久文件目录
  tempFilePath: /data/temp/   #临时文件目录
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
更新时间: 12/9/2021, 12:28:39 AM