当前位置: 代码网 > it编程>编程语言>Java > IDEA本地启动单元测试类-通过环境变量配置

IDEA本地启动单元测试类-通过环境变量配置

2024年08月06日 Java 我要评论
【代码】IDEA本地启动单元测试类-通过环境变量配置。

1.将本地的服务application.properties配置上环境变量

server.context-path=/
spring.http.encoding.charset=utf-8
spring.http.encoding.enabled=true
spring.http.encoding.force=true
server.port=8080
spring.application.name=dev
spring.jackson.time-zone=gmt+8
# datasource
spring.datasource.type=com.alibaba.druid.pool.druiddatasource
spring.datasource.initialize=false
spring.datasource.driverclassname=com.mysql.jdbc.driver
spring.datasource.druid.master.driver-class-name=com.mysql.jdbc.driver
spring.datasource.druid.master.url=jdbc:mysql://${mysql_host}:${mysql_port}/${mysql_db_p2p}?servertimezone=gmt%2b8&allowmultiqueries=true&characterencoding=utf-8 
spring.datasource.druid.master.username=${mysql_username}
spring.datasource.druid.master.password=${mysql_password}
spring.datasource.druid.slave.driver-class-name=com.mysql.jdbc.driver
spring.datasource.druid.slave.url=jdbc:mysql://${mysql_host}:${mysql_port}/${mysql_db_p2p}?servertimezone=gmt%2b8&allowmultiqueries=true&characterencoding=utf-8 
spring.datasource.druid.slave.username=${mysql_username}
spring.datasource.druid.slave.password=${mysql_password}
spring.datasource.tomcat.max-active=150
spring.datasource.tomcat.max-wait=60000
spring.datasource.tomcat.min-idle=10
spring.datasource.tomcat.validation-query=select 1
spring.datasource.tomcat.test-on-borrow=false
spring.datasource.tomcat.test-while-idle=true
spring.datasource.tomcat.time-between-eviction-runs-millis=18800
spring.datasource.tomcat.validation-interval=60000

# 分页
pagehelper.helperdialect=mysql
pagehelper.reasonable=true
pagehelper.supportmethodsarguments=true
pagehelper.params=count=countsql
pagehelper.returnpageinfo=check

# mybatis
mybatis.mapper-locations=classpath*:com/abc/**/**/*.xml
mybatis.type-aliases-package=com.abc.core.mybatis.bean

#actuator
#management.port=36662
#management.context-path=/


#---- upload file ----
spring.http.multipart.max-file-size=1024mb
spring.http.multipart.max-request-size=10240mb



file.upload.tempprefix=/usr/local/images
file.upload.prefix=/usr/local
file.upload.zcbpath=/images

spring.session.store-type=redis
#spring.redis.sentinel.master=mymaster
#spring.redis.sentinel.nodes=${redis_sentinel_nodes}
spring.redis.host=${redis_host}
spring.redis.port=${redis_port}
spring.redis.password=${redis_password}
spring.session.redis.namespace=zcb_test
# 连接池最大连接数(使用负值表示没有限制)
spring.redis.pool.max-active=1000
# 连接池最大阻塞等待时间(使用负值表示没有限制
spring.redis.pool.max-wait=20
# 连接池中的最大空闲连接
spring.redis.pool.max-idle=20
# 连接池中的最小空闲连接
spring.redis.pool.min-idle=10
# 连接超时时间(毫秒)
spring.redis.timeout=0


spring.thymeleaf.cache=false
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html
spring.thymeleaf.mode=html5
spring.thymeleaf.encoding=utf-8
spring.thymeleaf.content-type=text/html

#redis start
#redis.maxredirections=10
#redis.maxwaitmillis=1500
#redis.maxtotal=2048
#redis.minidle=20
#redis.maxidle=200
#redis.jedisclusternodes=127.0.0.1:6379
#redis end

#elasticsearch
#spring.data.elasticsearch.host=127.0.0.1
#spring.data.elasticsearch.host=172.17.169.66
#spring.data.elasticsearch.port=9301
#spring.data.elasticsearch.host=127.0.0.1
#spring.data.elasticsearch.port=9301
#spring.data.elasticsearch.local=false
#spring.data.elasticsearch.repositories.enabled=true
#spring.data.elasticsearch.cluster-name=elasticsearch
spring.data.elasticsearch.cluster-nodes=${es_host}
spring.data.elasticsearch.port=${es_port}

#---- aliyun sms 短信发送 ----
sms.templatecode=sms_12
sms.vendor.confirm.tip=sms_197455
sms.vendor.acceptcancel.tip=sms_19
sms.order.applycancel.tip=sms_19789
sms.vendor.refusecancel.tip=sms_197
sms.vendor.refuseorder=sms_19746
sms.ordertemplatecode=sms_1343
sms.ordercanceltemplatecode=sms_17
sms.accesskey=xxx
sms.accesssecret=389nreybb
cookie.domainname=bbb.com

#------ mongodb,name是登录名,pass是密码 ------
spring.data.mongodb.uri=mongodb://${mongod_user}:${mongod_password}@${mongod_host}:${mongod_port}/${mongod_database}
#spring.data.mongodb.uri=mongodb://10.19.11.194:27017/test
#spring.data.mongodb.uri=mongodb://name:pass@localhost:27017/test
# if spring data repository support is enabled
#spring.data.mongo.repositories.enabled=true

#---- 日志
spring.profiles=dev
#logging.config=classpath:logback-spring.xml
logging.path=logs
logging.file=log.log
logging.level.root=info
logging.level.com.abc.core.mapper=info
logging.level.com.abc=info
logging.level.org.springframework=info
logging.level.org.mybatis=info


#rabbitmq连接池
spring.rabbitmq.zcb.host=${rabbitmq_host}
spring.rabbitmq.zcb.port=${rabbitmq_port}
spring.rabbitmq.zcb.username=${rabbitmq_user}
spring.rabbitmq.zcb.password=${rabbitmq_password}
spring.rabbitmq.zcb.virtual-host=/${namespace_env}
spring.rabbitmq.listener.concurrency=10
spring.rabbitmq.listener.max-concurrency=300
spring.rabbitmq.listener.prefetch=100



#spring.mail.host=smtp
#spring.mail.port=465
#spring.mail.username=f@abc.com
#spring.mail.password=abc1



#spring.mail.host=abc.com
#spring.mail.port=26
#spring.mail.username=services@abc.com
#spring.mail.password=abcd
#
use.self.email=false

spring.mail.host=siyun.com
spring.mail.port=465
spring.mail.username=service@message.abc.com
spring.mail.password=kfx
spring.mail.default-encoding=utf-8
spring.mail.properties.mail.smtp.starttls.enable=true
spring.mail.properties.mail.smtp.starttls.required=true
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.socketfactory.class=javax.net.ssl.sslsocketfactory
spring.mail.properties.mail.smtp.timeout=3000
spring.mail.properties.mail.smtp.connectiontimeout=3000
spring.mail.properties.mail.smtp.socketfactory.port=465
spring.mail.properties.mail.smtp.port=465
spring.mail.properties.mail.transport.protocol=smtp


shiro.redis.hostname=10.38.177.61
shiro.redis.password=abc


site.buyer=https://buyer-${namespace_env}.bbb.com
site.vendor=https://supplier-${namespace_env}.bbb.com
site.login=https://buyer-${namespace_env}.bbb.com
site.bid=https://buyer-${namespace_env}.bbb.com
login.path=https://buyer-${namespace_env}.bbb.com/login
vd.login.path=https://supplier-${namespace_env}.bbb.com/login?loginsite=1


2.在src/test下加单元测试类

在这里插入图片描述

3.在idea edit configurations加environment variables配置

3.1点edit configurations

在这里插入图片描述

3.2 点击modify options 勾选

在这里插入图片描述

3.3 勾选上environment variables

在这里插入图片描述

3.4 配置 environment variables

在这里插入图片描述

3.5 整理好后粘贴在此处

在这里插入图片描述

3.6 环境变量举例,可直接粘贴

cookie_domain_url=xxx.com
domain_hs_bi=http://127.0.0.1:8080
domain_ops=ops-xxx.com
domain_supplier=supplier-xxx.com
es_cluster_name=10.66.88.117
es_host=10.101.15.44
es_password=none
es_port=9300
eureka_host=10.103.25.14
eureka_port=8761
mongod_database=xx
mongod_host=10.98.33.55
mongod_password=password123
mongod_port=27017
mongod_user=zcb
mysql_host=192.168.100.16
mysql_password=qfi9jccxxx
mysql_port=34
mysql_username=root
namespace_env=dev
rabbitmq_host=10.100.0.4
rabbitmq_password=guest
rabbitmq_port=5672
rabbitmq_user=guest
redis_db=0
redis_host=10.108.124.80
redis_password=jorvdxxxx
redis_port=6379
redis_timeout=10000
zookeeper_host=10.106.44.54
zookeeper_password=password
zookeeper_port=2181
mysql_db_contract=dev_contract
mysql_db_ops=dev_ops
mysql_db_p2p=dev_p2p
mysql_db_project=dev_project
mysql_db_rfp=dev_rfp
mysql_db_wms=dev_wms
skywalking_opts=enable
skywalking_host=skywalking-oap:11800

4.执行,debug

在这里插入图片描述

(0)

相关文章:

版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。

发表评论

验证码:
Copyright © 2017-2025  代码网 保留所有权利. 粤ICP备2024248653号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com