Access denied for user 'Administrator'@'172.16.12.34' (using password: YES)

今天启动系统时发现mysql报了这个错误

Access denied for user 'Administrator'@'172.16.12.34' (using password: YES)

问题就在Administrator这个用户名,但是我的系统里明明不是这个用户名
spring引入数据库配置的地方如下

<context:property-placeholder location="classpath:system.properties,classpath:druid-db-dev.properties" ignore-unresolvable="true"/>

其中druid-db-dev.properties属性文件中就是放了mysql的配置,其中用户名为username=test,可是怎么变为Administrator了呢,问题就在引入配置的方式
改为:

<context:property-placeholder location="classpath:system.properties,classpath:druid-db-dev.properties" system-properties-mode="NEVER" ignore-unresolvable="true"/>

就好了,多加了system-properties-mode=”NEVER”

再看spring-context.xsd对context:property-placeholder的解释

<xsd:element name="property-placeholder">
        <xsd:annotation>
            <xsd:documentation><![CDATA[
    Activates replacement of ${...} placeholders by registering a
    PropertySourcesPlaceholderConfigurer within the application context. Properties will
    be resolved against the specified properties file or Properties object -- so called
    "local properties", if any, and against the Spring Environment's current set of
    PropertySources.

    Note that as of Spring 3.1 the system-properties-mode attribute has been removed in
    favor of the more flexible PropertySources mechanism. However, Spring 3.1-based
    applications may continue to use the 3.0 (and older) versions of the spring-context
    schema in order to preserve system-properties-mode behavior. In this case, the
    traditional PropertyPlaceholderConfigurer component will be registered instead of the
    new PropertySourcesPlaceholderConfigurer.

    See ConfigurableEnvironment javadoc for more information on using.
            ]]></xsd:documentation>
            <xsd:appinfo>
                <tool:annotation>
                    <tool:exports type="org.springframework.context.support.PropertySourcesPlaceholderConfigurer"/>
                </tool:annotation>
            </xsd:appinfo>
        </xsd:annotation>
        <xsd:complexType>
            <xsd:complexContent>
                <xsd:extension base="propertyPlaceholder">
                    <xsd:attribute name="system-properties-mode" default="ENVIRONMENT">
                        <xsd:annotation>
                            <xsd:documentation><![CDATA[
    Controls how to resolve placeholders against system properties. As of Spring 3.1, this
    attribute value defaults to "ENVIRONMENT", indicating that resolution of placeholders
    against system properties is handled via PropertySourcesPlaceholderConfigurer and its
    delegation to the current Spring Environment object.

    For maximum backward compatibility, this attribute is preserved going forward with the
    3.1 version of the context schema, and any values other than the default "ENVIRONMENT"
    will cause a traditional PropertyPlaceholderConfigurer to be registered instead of the
    newer PropertySourcesPlaceholderConfigurer variant. In this case, the Spring Environment
    and its property sources are not interrogated when resolving placeholders. Users are
    encouraged to consider this attribute deprecated, and to take advantage of
    Environment/PropertySource mechanisms. See ConfigurableEnvironment javadoc for examples.

    "ENVIRONMENT" indicates placeholders should be resolved against the current Environment and against any local properties;
    "NEVER" indicates placeholders should be resolved only against local properties and never against system properties;
    "FALLBACK" indicates placeholders should be resolved against any local properties and then against system properties;
    "OVERRIDE" indicates placeholders should be resolved first against system properties and then against any local properties;
                            ]]></xsd:documentation>
                        </xsd:annotation>
                        <xsd:simpleType>
                            <xsd:restriction base="xsd:string">
                                <xsd:enumeration value="ENVIRONMENT"/>
                                <xsd:enumeration value="NEVER"/>
                                <xsd:enumeration value="FALLBACK"/>
                                <xsd:enumeration value="OVERRIDE"/>
                            </xsd:restriction>
                        </xsd:simpleType>
                    </xsd:attribute>
                </xsd:extension>
            </xsd:complexContent>
        </xsd:complexType>
    </xsd:element>

其中就有对NEVER的解释,”NEVER” indicates placeholders should be resolved only against local properties and never against system properties;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值