当我运行mvn安装时如何指定spring.profiles.active [英] How to specify spring.profiles.active when I run mvn install

查看:1821
本文介绍了当我运行mvn安装时如何指定spring.profiles.active的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用Spring的Web应用程序中,我为不同的部署环境创建了多个应用程序属性文件。它们指定不同的db连接配置。

  application-dev.properties 
application-qa.properties
application-stg.properties
application-prod.properties

根据。当我将其部署为战争时,似乎没有被拾取,因为我从tomcat中收到以下错误:

 无法实例化[javax.sql.DataSource]:Factory方法'dataSource'抛出异常


解决方案

在Run->运行配置下,选择您的maven启动配置,然后选择JRE选项卡,然后在VM参数文本区域中键入参数。


In this web application with Spring, I created several application-property files for different deploy environment. They specify different db connection configs.

application-dev.properties
application-qa.properties
application-stg.properties
application-prod.properties

The recommended way according to spring doc is to set spring.profiles.active as JVM option at run time, for example:

-Dspring.profiles.active=prod

However what should I do for deploying the application as war using mvn install. How should I set the spring profile? I am using Eclipse.

EDIT: I set the JVM option under . It does not seem to get picked up by maven when I deploy it as a war though since I got the following error from tomcat:

Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception

解决方案

Under Run->run configurations, select your maven launch configuration, then select the JRE tab, and type your argument in the VM arguments text area.

这篇关于当我运行mvn安装时如何指定spring.profiles.active的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆