美文网首页
IDEA运行Java Spring MVC应用提示异常,读取不到

IDEA运行Java Spring MVC应用提示异常,读取不到

作者: IT志男 | 来源:发表于2018-07-19 14:48 被阅读9次

问题

报异常,由于读取不到某些配置的属性导致初始化bean

解决

在IDEA中使用jetty:run运行Maven Java Spring MVC应用时指定Spring环境变量。

<context:property-placeholder location="classpath*:config-${spring.profiles.active}.properties"/>

因为在读取配置文件的xml中使用了环境变量来读取不同的配置文件

jetty:run -Dspring.profiles.active=test -f pom.xml

启动jar的示例

$ java -jar -Dspring.profiles.active=production demo-0.0.1-SNAPSHOT.jar

相关文章

网友评论

      本文标题:IDEA运行Java Spring MVC应用提示异常,读取不到

      本文链接:https://www.haomeiwen.com/subject/srjtmftx.html