当前位置: 首页 > news >正文

网站登录失败怎么回事二级域名免费分发

网站登录失败怎么回事,二级域名免费分发,b2b商务平台建设,求有题目做的学习网站1. 区分环境的配置 1.1. properties 配置 假设,一个应用的工作环境有:dev、test、prod 那么,我们可以添加 4 个配置文件: applcation.properties - 公共配置application-dev.properties - 开发环境配置application-test.proper…
1. 区分环境的配置
1.1. properties 配置

假设,一个应用的工作环境有:dev、test、prod
那么,我们可以添加 4 个配置文件:

  • applcation.properties - 公共配置
  • application-dev.properties - 开发环境配置
  • application-test.properties - 测试环境配置
  • application-prod.properties - 生产环境配置

在 applcation.properties 文件中可以通过以下配置来激活 profile:
spring.profiles.active = test
在这里插入图片描述

1.2. yml 配置

与 properties 文件类似,我们也可以添加 4 个配置文件:

  • applcation.yml - 公共配置
  • application-dev.yml - 开发环境配置
  • application-test.yml - 测试环境配置
  • application-prod.yml - 生产环境配置

在 applcation.yml 文件中可以通过以下配置来激活 profile:

spring:profiles:active: prod

此外,yml 文件也可以在一个文件中完成所有 profile 的配置:

# 激活 prod
spring:profiles:active: prod
# 也可以同时激活多个 profile
# spring.profiles.active: prod,proddb,prodlog
---
# dev 配置
spring:profiles: dev# 略去配置---
spring:profiles: test# 略去配置---
spring.profiles: prod
spring.profiles.include:- proddb- prodlog---
spring:profiles: proddb# 略去配置---
spring:profiles: prodlog
# 略去配置

注意:不同 profile 之间通过 — 分割

2. 区分环境的代码

使用 @Profile 注解可以指定类或方法在特定的 Profile 环境生效。

2.1. 修饰类
@Configuration
@Profile("production")
public class JndiDataConfig {@Bean(destroyMethod="")public DataSource dataSource() throws Exception {Context ctx = new InitialContext();return (DataSource) ctx.lookup("java:comp/env/jdbc/datasource");}
}
2.2. 修饰注解
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Profile("production")
public @interface Production {
}
2.3. 修饰方法
@Configuration
public class AppConfig {@Bean("dataSource")@Profile("development")public DataSource standaloneDataSource() {return new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.HSQL).addScript("classpath:com/bank/config/sql/schema.sql").addScript("classpath:com/bank/config/sql/test-data.sql").build();}@Bean("dataSource")@Profile("production")public DataSource jndiDataSource() throws Exception {Context ctx = new InitialContext();return (DataSource) ctx.lookup("java:comp/env/jdbc/datasource");}
}
3. 激活 profile
3.1. 插件激活 profile

spring-boot:run -Drun.profiles=prod

3.2. main 方法激活 profile

–spring.profiles.active=prod

3.3. jar 激活 profile

java -jar -Dspring.profiles.active=prod *.jar

3.4. 在 Java 代码中激活 profile

直接指定环境变量来激活 profile:

System.setProperty("spring.profiles.active", "test");

在 Spring 容器中激活 profile:

AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
ctx.getEnvironment().setActiveProfiles("development");
ctx.register(SomeConfig.class, StandaloneDataConfig.class, JndiDataConfig.class);
ctx.refresh();
http://www.hkea.cn/news/26862/

相关文章:

  • 网站首页滚动图片怎么做谷歌搜索关键词排名
  • 嵩县网站开发友情链接获取的途径有哪些
  • 国家企业信息公示网(广东)海南快速seo排名优化
  • 高端网站设计 上海徐州seo排名公司
  • 泰安网站建设公司排名石家庄最新消息
  • 域名只做邮箱没网站要备案吗常见的网络推广方式包括
  • 昆山建设局网站360搜索首页
  • 正常做网站多少钱无锡网站制作无锡做网站
  • php做网站csdn网站seo公司哪家好
  • 今日头条建站工具何鹏seo
  • wordpress 培训模板优化落实疫情防控新十条
  • 关于做外汇现货的网站太原整站优化排名外包
  • 星悦做任务网站是新网站百度收录
  • 十大营销网站seo关键词查询工具
  • 怎么查询网站所有关键词靠谱的广告联盟
  • 超酷的网站设计磁力搜索引擎
  • 网站建设写程序用什么软件成都疫情最新消息
  • 做网站需要什么资金2022今天刚刚发生地震了
  • 建设网站费用主要包括哪些google商店
  • 专注邯郸建设手机网站贴吧友情链接在哪
  • 网站备案拍照背景志鸿优化网官网
  • 网站百度知道怎么做推广网站搜索引擎优化的方法
  • 网站建设注意哪些问题sem和seo是什么职业岗位
  • 一_建设网站前的市场分析奶茶软文案例300字
  • 做网站智能工具江阴企业网站制作
  • 怎么看网站有没有做推广大数据营销系统多少钱
  • 广东工厂搜索seoseo平台优化服务
  • 网站开发平台 eclipseseo网站推广案例
  • 什么网站做调查能赚钱关键词优化报价推荐
  • 网站开发职业认知小结开发一个app平台大概需要多少钱?