将Java(Spring,Hibernate,MySql)项目从Windows迁移到Debian

sla*_*vig 0 java mysql spring hibernate mysql-error-1075

我在Windows上编写项目(IntelliJIdea),一切都好.它编译并运行.但是当我尝试在Debian(GNU/Linux 5.0)上运行时,我有

SEVERE: Access denied for user 'root'@'localhost' (using password: YES)
[java] 30.11.2010 15:39:04 org.hibernate.cfg.SettingsFactory buildSettings
[java] WARNING: Could not obtain connection to query metadata
[java] java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
[java] at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1075)
[java] at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3566)
[java] at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3498)
[java] at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:919)

我使用这样的Spring配置:

<bean id="mySqlDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
    <property name="url" value="jdbc:mysql://127.0.0.1:3306/mydb"/>
    <property name="username" value="mydb"/>
    <property name="password" value="Fallout_3"/>
</bean>

<bean id="mySqlSessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="dataSource" ref="mySqlDataSource"/>

    <property name="mappingResources">
        <list>
            <value>entities/ClientPrices.hbm.xml</value>
            <value>entities/User.hbm.xml</value>
            <value>entities/Provider.hbm.xml</value>
            <value>entities/MessageQueue.hbm.xml</value>
            <value> hibernate/SimpleEntity.hbm.xml</value>
        </list>
    </property>

    <property name="hibernateProperties">
        <value>
            hibernate.dialect=org.hibernate.dialect.MySQLDialect
            hibernate.show_sql=true
            hibernate.hbm2ddl.auto=create
            hibernate.current_session_context_class=thread
        </value>
    </property>

</bean>
Run Code Online (Sandbox Code Playgroud)

Jig*_*shi 5

您需要在mysql服务器中为roothost添加root权限

执行 :

GRANT ALL ON *.* TO 'root'@'localhost';
Run Code Online (Sandbox Code Playgroud)

在你的mysql控制台上.