当前位置: 首页 > 知识库问答 >
问题:

什么是解决这个错误,我面临的豆厂?

申嘉慕
2023-03-14

**Jun29, 2021 9:45:18PMorg.hibernate.版本logVersion INFO: HHH000412: HiberNate Core{5.2.8。最终}Jun29, 2021 9:45:19PMorg.hibernate.cfg.环境INFO: HHH000206:hibernate.properties未找到Jun29, 2021 9:45:19PMorg.hibernate.annotations.common.reflection.java.JavaRefltionManager INFO: HCANN000001: HiberNate Commons注释{5.0.1。最终}Tue Jun29 21:45:19PKT 2021警告:不建议在没有服务器身份验证的情况下建立SSL连接。根据MySQL5.5.45 , 5.6.26和5.7.6要求,如果未设置显式选项,则默认情况下必须建立SSL连接。为了符合不使用SSL的现有应用程序,验证服务器证书属性设置为“false”。您需要通过设置useSSL=false显式禁用SSL,或者设置useSSL=true并为服务器证书验证提供信任存储。Jun29, 2021 9:45:19PMorg.hibernate.engine.jdbc.env.internal.Jdbc环境发起者发起服务警告: HHH000342:无法获得查询元数据的连接:通信链接失败

这是我config.xml文件

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd">
<tx:annotation-driven />
<bean
    class="org.springframework.jdbc.datasource.DriverManagerDataSource"
    name="ds">
    <property name="driverClassName"
        value="com.mysql.jdbc.Driver" />
    <property name="url"
        value="jdbc:mysql://localhost:3306/springjdbc" />
    <property name="username" value="root" />
    <property name="password" value="root" />
</bean>

<bean
    class="org.springframework.orm.hibernate5.LocalSessionFactoryBean"
    name="factory">
    <property name="dataSource" ref="ds" />
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
            <prop key="hibernate.show_sql">true</prop>
            <prop key="hibernate.hbm2ddl.auto">update</prop>
        </props>
    </property>
    <property name="annotatedClasses">
        <list>
            <value>com.springDb.entities.Student</value>
        </list>
    </property>
</bean>  
<bean class="org.springframework.orm.hibernate5.HibernateTemplate"
    name="hibernateTemplat">
    <property name="sessionFactory" ref="factory"></property>

</bean>
    <bean class="com.springDb.Dao.StudentDao" name="studentDao">
        <property name="hibernateTemplate" ref="hibernateTemplat"></property>
    </bean>

    <bean
        class="org.springframework.orm.hibernate5.HibernateTransactionManager"
        name="transactionManager">
        <property name="sessionFactory" ref="factory"></property>
    </bean>


</beans>

学生课堂

package com.springDb.Dao;
import org.springframework.orm.hibernate5.HibernateTemplate;
import org.springframework.transaction.annotation.Transactional;
import com.springDb.entities.Student;

public class StudentDao {

private HibernateTemplate hibernateTemplate;

@Transactional
public int insert(Student student) {
    
    Integer r=(Integer)hibernateTemplate.save(student);
    return r;
}

public HibernateTemplate getHibernateTemplate() {
    return hibernateTemplate;
}

public void setHibernateTemplate(HibernateTemplate hibernateTemplate) {
    this.hibernateTemplate = hibernateTemplate;
}

public StudentDao(HibernateTemplate hibernateTemplate) {
    super();
    this.hibernateTemplate = hibernateTemplate;
}
public StudentDao() {


}}

学生班

package com.springDb.entities;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table(name = "Student_Info")
public class Student {
@Id
@Column(name = "Student_Id")
private int studentId;
@Column(name = "Student_Name")
private String studentName;
@Column(name = "Student_City")
private String studentCity;

public Student(int studentId, String studentName, String studentCity) {
    super();
    this.studentId = studentId;
    this.studentName = studentName;
    this.studentCity = studentCity;
}



public Student() {

}

public int getStudentId() {
    return studentId;
}

public void setStudentId(int studentId) {
    this.studentId = studentId;
}

public String getStudentName() {
    return studentName;
}

public void setStudentName(String studentName) {
    this.studentName = studentName;
}

public String getStudentCity() {
    return studentCity;
}

public void setStudentCity(String studentCity) {
    this.studentCity = studentCity;
}

}
    

pp.java班

package com.springDb;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.springDb.Dao.StudentDao;
import com.springDb.entities.Student;

/**
 * Hello world!
 *
 */
public class App 
{
    public static void main( String[] args )
    {
       ApplicationContext context= new ClassPathXmlApplicationContext("config.xml");
       StudentDao studentDao = context.getBean("studentDao",StudentDao.class);
       
       Student student=new Student(1233,"Hery","Turky");
      
       int r = studentDao.insert(student);
       System.out.println("Done"+r);
    }
}
    
    

共有1个答案

秦阳旭
2023-03-14

无论您使用的是哪个版本的Spring/Hibernate,它都与您使用的Java版本不兼容。尝试更新Spring/Hibernate或使用旧的Java版本。

 类似资料:
  • 当我试图通过heroku打开我正在处理的应用程序时,我得到了一个应用程序错误。我查看了heroku日志,发现以下错误: “错误H10(应用程序崩溃)- 我不确定错误指的是什么,或者我如何解决导致错误的问题。你能给的任何帮助都会很棒!

  • 失败:生成失败,出现异常。 > 其中:Script“C:\flutter\packages\flutter_tools\gradle\flutter.gradle”行:900 错误:任务“:app:CompileFlutterBuildDebug”执行失败。 进程“command”C:\flutter\bin\flutter.bat“已完成,退出值为非零%1 生成在%12s中失败异常:Gradle

  • 问题内容: 我有一些代码,执行时会抛出NoReverseMatch,说: 这是什么意思,我该怎么办? 问题答案: 该NoReverseMatch错误是说,Django中找不到你在任何已安装的应用程序网址提供的URL匹配的URL模式。 当无法根据提供的参数识别URLconf中的匹配URL时,django.core.urlresolvers会引发NoReverseMatch异常。 要开始调试它,你需要

  • 问题内容: 我试图从E3roid示例运行示例。除了我什么时候,我都会在页面上强行关闭。这是logcat错误。通过查看它,您能否告诉我这意味着什么,什么问题? 问题答案: 您是否已将AndroidActivity添加到AndroidManifest?

  • 问题内容: 有人可以发现我的错误吗,这应该是SQL中的合法查询吗? ON子句中的未知列u.usr_auto_key 这是数据库模式: 这是查询… 问题答案: 尝试切换,并在from子句中:

  • {“error”:“invalid_scope”,“error_description”:“AADSTS70011:为输入参数”scope“提供的值无效。作用域 https://graph.microsoft.com/User.Read https://graph.microsoft.com/User.ReadWrite https://graph.microsoft.com/User.ReadB