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

来源:互联网 发布:淘宝 非典 编辑:程序博客网 时间:2024/06/01 12:32

今天启动系统时发现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
原创粉丝点击