gpt4 book ai didi

java - 将 Java(Spring、Hibernate、MySql)项目从 Windows 迁移到 Debian

转载 作者:太空宇宙 更新时间:2023-11-03 10:27:30 25 4
gpt4 key购买 nike

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

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

我使用这样的 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>

最佳答案

您需要在您的 mysql 服务器中为本地主机添加 root 权限

执行:

GRANT ALL ON *.* TO 'root'@'localhost';

在你的 mysql 控制台上。

关于java - 将 Java(Spring、Hibernate、MySql)项目从 Windows 迁移到 Debian,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4314450/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com