Name spring.profiles.active is not bound in this Context

wl8685 2015-08-31 03:47:54
要修改一个项目,用的技术有springMVC,maven等,部署到tomcat下,启动时报错。项目中使用的连接池连接数据库,没有使用JNDI,为什么启动时老是去查找JNDI?
applicationContext.xml中定义了项目的环境:

<!-- local development环境 -->
<beans profile="development">
<context:property-placeholder ignore-resource-not-found="true"
location="classpath*:/application.properties" />

<!-- Tomcat JDBC连接池 -->
<bean id="dataSource" class="org.apache.tomcat.jdbc.pool.DataSource" destroy-method="close">
<property name="driverClassName" value="${jdbc.driver}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
<property name="defaultAutoCommit" value="false" />
</bean>
</beans>


pom.xml中设置了spring.profiles.active

<!-- jetty插件, 设定context path与spring profile -->
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty.version}</version>
<configuration>
<systemProperties>
<systemProperty>
<name>spring.profiles.active</name>
<value>development</value>
</systemProperty>
</systemProperties>
<useTestClasspath>true</useTestClasspath>

<webAppConfig>
<contextPath>/${project.artifactId}</contextPath>
</webAppConfig>
</configuration>
</plugin>

==========启动日志==========
13:57:46.586 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'spring.profiles.active' in [servletConfigInitParams]
13:57:46.586 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'spring.profiles.active' in [servletContextInitParams]
13:57:46.586 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'spring.profiles.active' in [jndiProperties]
13:57:46.586 [main] DEBUG o.springframework.jndi.JndiTemplate - Looking up JNDI object with name [java:comp/env/spring.profiles.active]
13:57:46.586 [main] DEBUG o.s.jndi.JndiLocatorDelegate - Converted JNDI name [java:comp/env/spring.profiles.active] not found - trying original name [spring.profiles.active]. javax.naming.NameNotFoundException: Name spring.profiles.active is not bound in this Context
13:57:46.586 [main] DEBUG o.springframework.jndi.JndiTemplate - Looking up JNDI object with name [spring.profiles.active]
13:57:46.586 [main] DEBUG o.s.jndi.JndiPropertySource - JNDI lookup for name [spring.profiles.active] threw NamingException with message: Name spring.profiles.active is not bound in this Context. Returning null.
13:57:46.586 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'spring.profiles.active' in [systemProperties]
13:57:46.586 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'spring.profiles.active' in [systemEnvironment]
13:57:46.586 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Could not find key 'spring.profiles.active' in any property source. Returning [null]

.....
......
13:57:46.836 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'jdbc.driver' in [environmentProperties]
13:57:46.836 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'jdbc.driver' in [servletConfigInitParams]
13:57:46.836 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'jdbc.driver' in [servletContextInitParams]
13:57:46.836 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'jdbc.driver' in [jndiProperties]
13:57:46.836 [main] DEBUG o.springframework.jndi.JndiTemplate - Looking up JNDI object with name [java:comp/env/jdbc.driver]
13:57:46.836 [main] DEBUG o.s.jndi.JndiLocatorDelegate - Converted JNDI name [java:comp/env/jdbc.driver] not found - trying original name [jdbc.driver]. javax.naming.NameNotFoundException: Name jdbc.driver is not bound in this Context
13:57:46.836 [main] DEBUG o.springframework.jndi.JndiTemplate - Looking up JNDI object with name [jdbc.driver]
13:57:46.836 [main] DEBUG o.s.jndi.JndiPropertySource - JNDI lookup for name [jdbc.driver] threw NamingException with message: Name jdbc.driver is not bound in this Context. Returning null.
13:57:46.836 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'jdbc.driver' in [systemProperties]
13:57:46.836 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'jdbc.driver' in [systemEnvironment]
13:57:46.836 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Could not find key 'jdbc.driver' in any property source. Returning [null]
13:57:46.836 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'jdbc.driver' in [localProperties]
13:57:46.836 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Found key 'jdbc.driver' in [localProperties] with type [String] and value 'com.mysql.jdbc.Driver'
13:57:46.836 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'jdbc.url' in [environmentProperties]
13:57:46.836 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'jdbc.url' in [servletConfigInitParams]
13:57:46.836 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'jdbc.url' in [servletContextInitParams]
13:57:46.836 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'jdbc.url' in [jndiProperties]
13:57:46.836 [main] DEBUG o.springframework.jndi.JndiTemplate - Looking up JNDI object with name [java:comp/env/jdbc.url]
13:57:46.836 [main] DEBUG o.s.jndi.JndiLocatorDelegate - Converted JNDI name [java:comp/env/jdbc.url] not found - trying original name [jdbc.url]. javax.naming.NameNotFoundException: Name jdbc.url is not bound in this Context
13:57:46.836 [main] DEBUG o.springframework.jndi.JndiTemplate - Looking up JNDI object with name [jdbc.url]
13:57:46.836 [main] DEBUG o.s.jndi.JndiPropertySource - JNDI lookup for name [jdbc.url] threw NamingException with message: Name jdbc.url is not bound in this Context. Returning null.
13:57:46.836 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'jdbc.url' in [systemProperties]
13:57:46.836 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'jdbc.url' in [systemEnvironment]
13:57:46.836 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Could not find key 'jdbc.url' in any property source. Returning [null]
13:57:46.836 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'jdbc.url' in [localProperties]
13:57:46.836 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Found key 'jdbc.url' in [localProperties] with type [String] and value 'jdbc:mysql://127.0.0.1:3306/drolohq?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull'
13:57:46.836 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'jdbc.username' in [environmentProperties]
13:57:46.836 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'jdbc.username' in [servletConfigInitParams]
13:57:46.836 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'jdbc.username' in [servletContextInitParams]
13:57:46.836 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'jdbc.username' in [jndiProperties]
13:57:46.836 [main] DEBUG o.springframework.jndi.JndiTemplate - Looking up JNDI object with name [java:comp/env/jdbc.username]
13:57:46.836 [main] DEBUG o.s.jndi.JndiLocatorDelegate - Converted JNDI name [java:comp/env/jdbc.username] not found - trying original name [jdbc.username]. javax.naming.NameNotFoundException: Name jdbc.username is not bound in this Context
13:57:46.836 [main] DEBUG o.springframework.jndi.JndiTemplate - Looking up JNDI object with name [jdbc.username]
13:57:46.836 [main] DEBUG o.s.jndi.JndiPropertySource - JNDI lookup for name [jdbc.username] threw NamingException with message: Name jdbc.username is not bound in this Context. Returning null.
13:57:46.836 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'jdbc.username' in [systemProperties]
13:57:46.836 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'jdbc.username' in [systemEnvironment]
13:57:46.836 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Could not find key 'jdbc.username' in any property source. Returning [null]
13:57:46.836 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'jdbc.username' in [localProperties]
13:57:46.836 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Found key 'jdbc.username' in [localProperties] with type [String] and value 'root'
...全文
658 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
wl8685 2015-09-01
  • 打赏
  • 举报
回复
求大神指导
wl8685 2015-09-01
  • 打赏
  • 举报
回复
修改web.xml后启动不再报Name spring.profiles.active is not bound in this Context了 修改前:

<context-param>
        <param-name>spring.profiles.defualt</param-name>
        <param-value>development</param-value>
    </context-param>
修改后:

<context-param>
        <param-name>spring.profiles.active</param-name>
        <param-value>development</param-value>
    </context-param>

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧