后台配置页面application.yml和application-dev.yml文件是配置和getway关联的重要文件
一般我们使用到getway,它能定时扫描到将当前后台application-dev.yml和application.yml配置文件配置了这个getway服务的地址,然后一目了然看到所有挂在getway上的服务,如下是配置文件的部分详解:
(1)application.yml文件(zzzzzz指代你的服务名)
eureka:
instance:
appname: zzzzzz
instanceId: zzzzzz:${random.value}
statusPageUrlPath: ${management.context-path}/info
healthCheckUrlPath: ${management.context-path}/health
prefer-ip-address: true
client:
enabled: true #当enabled设置为true时,则允许挂在getway上,否则设置为false时,则只能在本地调用
healthcheck:
enabled: true
registerWithEureka: true
fetchRegistry: true
(2)application-dev.yml文件(xxx代指你的参数,zzzzzz指代你的服务名)
eureka:
client:
serviceUrl:
defaultZone: http://admin:admin@XXX.XXX.X.XXX:XXX/eureka/ #第一个admin是登录账号,第二个是admin登录密码,XXX.XXX.X.XXX是getway地址
spring:
datasource:
# type: com.zaxxer.hikari.HikariDataSource
# url: jdbc:mysql://XXX.XXX.X.XXX:3306/hm_common?useUnicode=true&characterEncoding=utf8&useSSL=false
# username: root
# password: XXX ##这一部分注释掉的是配置mysql数据库的数据源连接
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: oracle.jdbc.driver.OracleDriver
url: jdbc:oracle:thin:@XXX.XXX.X.XXX:1521:XXXX
username: XXXX
password: XXXX ##这一部分没注释掉的是配置ORACLE数据库的数据源连接
server:
port: 8081 ##这个端口是配置服务的端口号。举个例子:倘若服务运行后,被调用的接口地址是http://XXX.XXX.X.XXX:8081
compression:
enabled: true
mime-types: text/html,text/xml,text/plain,text/css, application/javascript, application/json
min-response-size: 1024
jhipster:
http:
cache:
timeToLiveInDays: 1461
security:
authentication:
jwt:
secret: 251cbd4XXXX909XXXXXXXXXf89d3cec5c703##唯一识别是否能调用getway上的服务的编码,secret这串字符串编码了getway的验证信息
token-validity-in-seconds: 86400
token-validity-in-seconds-for-remember-me: 2592000
#cors:
#allowed-origins: "*"
#allowed-methods: GET, PUT, POST, DELETE, OPTIONS
#allowed-headers: "*"
#exposed-headers:
#allow-credentials: true
#max-age: 1800 ##从cors到这行的代码作用是是否跳过getway验证直接调用接口,注释掉这段代码则是需要getway验证,否则跳过验证
application:
# security:
# permit: /api/XXXXXXXX
gateway:
username: xxxx
password: xxxx
rocketmq:
enable: false
namesrvAddr: XXX.XXX.X.XXX:xxxx
produceGroup: zzzzzz_produce
consumerGroup: zzzzzz_consumer
consumerTopic: zzzzzz
mybatis: #mybatis的mapper配置路径
config-location: classpath:config/mybatis/config/oracle/mybatis-frame.xml
# config-location: classpath:config/mybatis/config/mysql/mybatis-frame.xml
mapper-locations: classpath*:config/mybatis/mappers/oracle/**/*.xml
# mapper-locations: classpath*:config/mybatis/mappers/mysql/**/*.xml
还有一些docker文件和和pom.xml文件配置有空会继续更新