spring mvc读取.properties配置文件异常
springmvc读取mysql的.properties配置文件异常,配置文件中的username读成了系统用户,.properties配置文件如下:driverClas...
spring mvc读取mysql的.properties配置文件异常,配置文件中的username读成了系统用户,
.properties配置文件如下:
driverClassName:com.mysql.jdbc.Driver
url:jdbc:mysql://localhost:3306/mywebappdb
userName:root
password:root
filters:stat
maxActive:20
initialSize:1
maxWait:60000
minIdle:10
#maxIdle:15
timeBetweenEvictionRunsMillis:60000
minEvictableIdleTimeMillis:300000
validationQuery:SELECT 'x'
testWhileIdle:true
testOnBorrow:false
testOnReturn:false
#poolPreparedStatements:true
maxOpenPreparedStatements:20
removeAbandoned:true
removeAbandonedTimeout:1800
logAbandoned:true
spring配置如下:
<!-- 引入jdbc配置文件 -->
<context:property-placeholder location="classpath*:/properties/dbconfig.properties"/>
<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" destroy-method="close">
<!-- 数据源驱动类可不写,Druid默认会自动根据URL识别DriverClass -->
<property name="driverClassName" value="${driverClassName}" />
<!-- 数据库url连接 -->
<property name="url" value="${url}" />
<!-- 用户名 -->
<property name="username" value="${username}" />
<!-- 密码 -->
<property name="password" value="${password}" />
.......此处省略
</bean>
在启动jboss时却报如下错误:
15:03:36,154 ERROR [com.alibaba.druid.pool.DruidDataSource] (MSC service thread 1-12) dataSource init error: java.sql.SQLException: Access denied for user 'Administrator'@'localhost' (using password: YES)
怎么配置文件中的“root”变成了“Administrator”?Administrator是当前操作系统用户
.properties配置中的userName:root是username而不是userName,笔误写错了! 展开
.properties配置文件如下:
driverClassName:com.mysql.jdbc.Driver
url:jdbc:mysql://localhost:3306/mywebappdb
userName:root
password:root
filters:stat
maxActive:20
initialSize:1
maxWait:60000
minIdle:10
#maxIdle:15
timeBetweenEvictionRunsMillis:60000
minEvictableIdleTimeMillis:300000
validationQuery:SELECT 'x'
testWhileIdle:true
testOnBorrow:false
testOnReturn:false
#poolPreparedStatements:true
maxOpenPreparedStatements:20
removeAbandoned:true
removeAbandonedTimeout:1800
logAbandoned:true
spring配置如下:
<!-- 引入jdbc配置文件 -->
<context:property-placeholder location="classpath*:/properties/dbconfig.properties"/>
<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" destroy-method="close">
<!-- 数据源驱动类可不写,Druid默认会自动根据URL识别DriverClass -->
<property name="driverClassName" value="${driverClassName}" />
<!-- 数据库url连接 -->
<property name="url" value="${url}" />
<!-- 用户名 -->
<property name="username" value="${username}" />
<!-- 密码 -->
<property name="password" value="${password}" />
.......此处省略
</bean>
在启动jboss时却报如下错误:
15:03:36,154 ERROR [com.alibaba.druid.pool.DruidDataSource] (MSC service thread 1-12) dataSource init error: java.sql.SQLException: Access denied for user 'Administrator'@'localhost' (using password: YES)
怎么配置文件中的“root”变成了“Administrator”?Administrator是当前操作系统用户
.properties配置中的userName:root是username而不是userName,笔误写错了! 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询