Alibaba_equals与hashCode的关系

1、equals()与hashCode()的关系
1)哈希算法:简单地说哈希算法就是经过一系列的运算,将任意字符串A计算成字符串B或者是数字B,通常来说从A能够生成B而从B则无法通过反计算生成A。该算法常常用于加密,常见的哈希算法实现有MD5、SHA1等
2)hashCode()方法的定义,在Java API文档中,hashCode()方法定义于java.lang.Object类中,public int hashCode(),运行该方法返回的是该对象的哈希码值,hashCode方法的常规规定是:

  • 在 Java 应用程序执行期间,在对同一对象多次调用hashCode 方法时,必须一致地返回相同的整数,前提是将对象进行equals 比较时所用的信息没有被修改。从某一应用程序的一次执行到同一应用程序的另一次执行,该整数无需保持一致。
  • 如果根据 equals(Object) 方法,两个对象是相等的,那么对这两个对象中的每个对象调用hashCode 方法都必须生成相同的整数结果。
  • 如果根据 equals(Object) 方法,两个对象不相等,那么对这两个对象中的任一对象上调用hashCode 方法不 要求一定生成不同的整数结果。但是,程序员应该意识到,为不相等的对象生成不同整数结果可以提高哈希表的性能。
实际上,Java是根据当前对象的内存地址值来计算得到对象的哈希值的。
3)equals()也定义于java.lang.Object类中,public boolean equals(Object obj),在没有重写的情况下,对于任何非空引用值x与y,当且仅当x与y引用了同一个对象时,该方法返回真。需要注意的是:当某个类的equals方法被重写的时候,通常需要重写hashCode()方法,以维护hashCode方法的常规协定(即上面提到:如果两个对象根据equals方法判断是相等的,那么对这两个对象中的每个对象调用hashCode方法都必须生成相同的整数结果)。

比如String类的equals方法判断的依据不是“==”的内存地址,而是字符串里面的字符,那么String重写的hashCode方法的哈希码计算也应该是基于字符串里面的字符的。(参考Java String类的源代码)

所以我们可以得到equals方法与hashCode方法的关系如下:

经过equals判断相等的两个对象,他们经过hashCode方法计算而得的哈希码一定相等;

反过来说,执行hashCode方法得到不一样的哈希码的两个对象,经过equals判断肯定是不相等的;

而经过equals判断不相等的两个对象,由hashCode方法计算得到的哈希码却不一定不相等;反过来说由hashCode方法计算得到的哈希码相同的两个对象,由equals方法判断不一定是相等的。这个我们将在下面的例子得到验证。

假如我们要构建一个哈希表,哈希函数使用模5取余算法,则根据现有数据 1 2 3 4 5 我们可以得到下面的哈希表

0:5

1:1

2:2

3:3

4:4

这样子的哈希表有什么用途呢?在Java中,哈希表的构建常常用于hashSet/hashMap/hashTable等持有对象,以hashSet为例,Set是不允许插入重复的值的,所以在每一次插入值的时候Set都必须检查已有的数据里是否有与新进的数据相同的数据存在。

假设当前hashSet已经有成千上万的数据,为了时间的效率问题,我们自然会避开一一检查的思路。使用当前的对象(在这里为自然数)的哈希码(Java里由hashCode获得但是这里使用的是我们自定义的模5取余算法),根据哈希码在哈希表里找到该哈希码对应的已存在的数据,再根据equals方法进行比较,最终可以确定hashSet里是否已经含有该新值,从而减少了比较的次数,提高了时间的效率。

我们接着插入7 12 和 17 则哈希的结果为:

0:5

1:1

2:2 7 12 17

3:3

4:4

hash算法的初衷是使得取一个值变得容易,而事实是这也是最快的取值方法。所以哈希码自然是一对多的设计,这也证明了hashCode方法返回的哈希码一样的两个对象,并不一定是相等的两个对象。而equals不相等的两个对象,哈希码也不一定是不相等的。

==============================番外===================================

我们试定义一个这样子的类:

public class Man {
    public int age;
    public String name;
    public Man(int age,String name){
    	this.age = age;
    	this.name = name;
    }
    /**
     * 重写equals!
     */
    public boolean equals(Object obj){//注意参数为Object类型
        Man m = (Man)Obj;
    	return this.age == m.age && this.name.equals(m.name);
    }
}

import java.util.HashSet;
import java.util.Set;
public class Main {
   public static void main(String[] args){
	   Set<Man> hs = new HashSet<Man>();
	   hs.add(new Man(1,"SunZhongShan"));
	   hs.add(new Man(2,"MaoZeDong"));
	   hs.add(new Man(3,"ZhouEnLai"));
	   hs.add(new Man(1,"SunZhongShan"));
	   for(Man m : hs){
		   System.out.println(m.age +" "+ m.name);
	   }
	   Man m1 = new Man(1,"SunZhongShan");
	   Man m2 = new Man(1,"SunZhongShan");
	   System.out.println(m1.equals(m2));
   }
}

运行结果为:

1 SunZhongShan
1 SunZhongShan
3 ZhouEnLai
2 MaoZeDong
true

beta2:

public class Man {
    public int age;
    public String name;
    public Man(int age,String name){
    	this.age = age;
    	this.name = name;
    }
    /**
     * 重写equals!
     */
    public boolean equals(Object obj){
    	Man m = (Man)obj;
    	return this.age == m.age && this.name.equals(m.name);
    }
    public int hashCode(){
    	return age * name.hashCode();
    }
}
import java.util.HashSet;
import java.util.Set;
public class Main {
   public static void main(String[] args){
	   Set<Man> hs = new HashSet<Man>();
	   hs.add(new Man(1,"SunZhongShan"));
	   hs.add(new Man(1,"SunZhongShan"));
	   hs.add(new Man(2,"MaoZeDong"));
	   hs.add(new Man(3,"ZhouEnLai"));
	   for(Man m : hs){
		   System.out.println(m.age + " " + m.name);
	   }
   }
}

运行结果:

3 ZhouEnLai
2 MaoZeDong
1 SunZhongShan


nohup: 忽略输入 SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/usr/local/code/mapletr4j-2.1.0-alpha-2/mapletr4j-2.1.0-alpha-2-exec.jar!/BOOT-INF/lib/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/usr/local/code/mapletr4j-2.1.0-alpha-2/mapletr4j-2.1.0-alpha-2-exec.jar!/BOOT-INF/lib/log4j-slf4j-impl-2.13.3.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/usr/local/code/mapletr4j-2.1.0-alpha-2/mapletr4j-2.1.0-alpha-2-exec.jar!/BOOT-INF/lib/slf4j-log4j12-1.7.30.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/usr/local/code/mapletr4j-2.1.0-alpha-2/mapletr4j-2.1.0-alpha-2-exec.jar!/BOOT-INF/lib/slf4j-reload4j-1.7.36.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder] _______ _______ _________ _ _______ _______ _______ _______ _______ _ _______ _________ _______ ___ _________ ( ____ )( ___ )\__ __/( ( /|( ____ \( ____ \ ( )( ___ )( ____ )( \ ( ____ \\__ __/( ____ ) / )\__ _/ | ( )|| ( ) | ) ( | \ ( || ( \/| ( \/ | () () || ( ) || ( )|| ( | ( \/ ) ( | ( )| / /) | ) ( | (____)|| (___) | | | | \ | || (__ | (__ | || || || (___) || (____)|| | | (__ | | | (____)| / (_) (_ | | | __)| ___ | | | | (\ \) || __) | __) | |(_)| || ___ || _____)| | | __) | | | __)(____ _) | | | (\ ( | ( ) | | | | | \ || ( | ( | | | || ( ) || ( | | | ( | | | (\ ( ) ( | | | ) \ \__| ) ( |___) (___| ) \ || ) | (____/\ | ) ( || ) ( || ) | (____/\| (____/\ | | | ) \ \__ | ||\_) ) |/ \__/|/ \|\_______/|/ )_)|/ (_______/ |/ \||/ \||/ (_______/(_______/ )_( |/ \__/ (_)(____/ 23:11:05.686 [main] INFO com.rainfe.WebApplication - Starting WebApplication v2.1.0-alpha-2 using Java 1.8.0_312 on localhost.localdomain with PID 97111 (/usr/local/code/mapletr4j-2.1.0-alpha-2/mapletr4j-2.1.0-alpha-2-exec.jar started by root in /usr/local/code/mapletr4j-2.1.0-alpha-2) 23:11:05.695 [main] INFO com.rainfe.WebApplication - The following profiles are active: db,activiti,kkfileview 23:11:53.488 [main] WARN o.m.s.mapper.ClassPathMapperScanner - Skipping MapperFactoryBean with name 'parameterSettingMapper' and 'com.rainfe.mapletr.dps.parameterSetting.mapper.ParameterSettingMapper' mapperInterface. Bean already defined with the same name! 23:11:53.488 [main] WARN o.m.s.mapper.ClassPathMapperScanner - Skipping MapperFactoryBean with name 'datasetApiMapper' and 'com.rainfe.mapletr.bigscreen.module.dataset.mapper.DatasetApiMapper' mapperInterface. Bean already defined with the same name! 23:11:53.488 [main] WARN o.m.s.mapper.ClassPathMapperScanner - Skipping MapperFactoryBean with name 'datasetApiParamMapper' and 'com.rainfe.mapletr.bigscreen.module.dataset.mapper.DatasetApiParamMapper' mapperInterface. Bean already defined with the same name! 23:11:53.488 [main] WARN o.m.s.mapper.ClassPathMapperScanner - Skipping MapperFactoryBean with name 'datasetComponentMapper' and 'com.rainfe.mapletr.bigscreen.module.dataset.mapper.DatasetComponentMapper' mapperInterface. Bean already defined with the same name! 23:11:53.488 [main] WARN o.m.s.mapper.ClassPathMapperScanner - Skipping MapperFactoryBean with name 'datasetDocumentMapper' and 'com.rainfe.mapletr.bigscreen.module.dataset.mapper.DatasetDocumentMapper' mapperInterface. Bean already defined with the same name! 23:11:53.488 [main] WARN o.m.s.mapper.ClassPathMapperScanner - Skipping MapperFactoryBean with name 'datasetFileMapper' and 'com.rainfe.mapletr.bigscreen.module.dataset.mapper.DatasetFileMapper' mapperInterface. Bean already defined with the same name! 23:11:53.488 [main] WARN o.m.s.mapper.ClassPathMapperScanner - Skipping MapperFactoryBean with name 'datasetGroupMapper' and 'com.rainfe.mapletr.bigscreen.module.dataset.mapper.DatasetGroupMapper' mapperInterface. Bean already defined with the same name! 23:11:53.488 [main] WARN o.m.s.mapper.ClassPathMapperScanner - Skipping MapperFactoryBean with name 'datasetSourceMapper' and 'com.rainfe.mapletr.bigscreen.module.dataset.mapper.DatasetSourceMapper' mapperInterface. Bean already defined with the same name! 23:11:53.488 [main] WARN o.m.s.mapper.ClassPathMapperScanner - Skipping MapperFactoryBean with name 'datasetSqlMapper' and 'com.rainfe.mapletr.bigscreen.module.dataset.mapper.DatasetSqlMapper' mapperInterface. Bean already defined with the same name! 23:11:53.489 [main] WARN o.m.s.mapper.ClassPathMapperScanner - Skipping MapperFactoryBean with name 'datasetTransformMapper' and 'com.rainfe.mapletr.bigscreen.module.dataset.mapper.DatasetTransformMapper' mapperInterface. Bean already defined with the same name! 23:11:53.489 [main] WARN o.m.s.mapper.ClassPathMapperScanner - Skipping MapperFactoryBean with name 'datasetSocketMapper' and 'com.rainfe.mapletr.bigscreen.module.design.mapper.DatasetSocketMapper' mapperInterface. Bean already defined with the same name! 23:11:53.489 [main] WARN o.m.s.mapper.ClassPathMapperScanner - Skipping MapperFactoryBean with name 'designComponentsMapper' and 'com.rainfe.mapletr.bigscreen.module.design.mapper.DesignComponentsMapper' mapperInterface. Bean already defined with the same name! 23:11:53.489 [main] WARN o.m.s.mapper.ClassPathMapperScanner - Skipping MapperFactoryBean with name 'designDataMapper' and 'com.rainfe.mapletr.bigscreen.module.design.mapper.DesignDataMapper' mapperInterface. Bean already defined with the same name! 23:11:53.489 [main] WARN o.m.s.mapper.ClassPathMapperScanner - Skipping MapperFactoryBean with name 'designGeoDataMapper' and 'com.rainfe.mapletr.bigscreen.module.design.mapper.DesignGeoDataMapper' mapperInterface. Bean already defined with the same name! 23:11:53.489 [main] WARN o.m.s.mapper.ClassPathMapperScanner - Skipping MapperFactoryBean with name 'designGroupMapper' and 'com.rainfe.mapletr.bigscreen.module.design.mapper.DesignGroupMapper' mapperInterface. Bean already defined with the same name! 23:11:53.489 [main] WARN o.m.s.mapper.ClassPathMapperScanner - Skipping MapperFactoryBean with name 'designImgGroupMapper' and 'com.rainfe.mapletr.bigscreen.module.design.mapper.DesignImgGroupMapper' mapperInterface. Bean already defined with the same name! 23:11:53.489 [main] WARN o.m.s.mapper.ClassPathMapperScanner - Skipping MapperFactoryBean with name 'designImgPoolMapper' and 'com.rainfe.mapletr.bigscreen.module.design.mapper.DesignImgPoolMapper' mapperInterface. Bean already defined with the same name! 23:11:53.489 [main] WARN o.m.s.mapper.ClassPathMapperScanner - Skipping MapperFactoryBean with name 'designModelMapper' and 'com.rainfe.mapletr.bigscreen.module.design.mapper.DesignModelMapper' mapperInterface. Bean already defined with the same name! 23:11:53.489 [main] WARN o.m.s.mapper.ClassPathMapperScanner - Skipping MapperFactoryBean with name 'designShareMapper' and 'com.rainfe.mapletr.bigscreen.module.design.mapper.DesignShareMapper' mapperInterface. Bean already defined with the same name! 23:11:53.489 [main] WARN o.m.s.mapper.ClassPathMapperScanner - Skipping MapperFactoryBean with name 'sqlExecuteMapper' and 'com.rainfe.mapletr.bigscreen.module.design.mapper.SqlExecuteMapper' mapperInterface. Bean already defined with the same name! 23:11:53.489 [main] WARN o.m.s.mapper.ClassPathMapperScanner - Skipping MapperFactoryBean with name 'cameraMapper' and 'com.rainfe.mapletr.bigscreen.module.easymedia.mapper.CameraMapper' mapperInterface. Bean already defined with the same name! 23:11:53.489 [main] WARN o.m.s.mapper.ClassPathMapperScanner - Skipping MapperFactoryBean with name 'sysAccessMapper' and 'com.rainfe.mapletr.bigscreen.module.system.mapper.SysAccessMapper' mapperInterface. Bean already defined with the same name! 23:11:53.489 [main] WARN o.m.s.mapper.ClassPathMapperScanner - Skipping MapperFactoryBean with name 'sysDictMapper' and 'com.rainfe.mapletr.bigscreen.module.system.mapper.SysDictMapper' mapperInterface. Bean already defined with the same name! 23:11:53.489 [main] WARN o.m.s.mapper.ClassPathMapperScanner - Skipping MapperFactoryBean with name 'sysLogMapper' and 'com.rainfe.mapletr.bigscreen.module.system.mapper.SysLogMapper' mapperInterface. Bean already defined with the same name! 23:11:53.489 [main] WARN o.m.s.mapper.ClassPathMapperScanner - Skipping MapperFactoryBean with name 'sysMailJobMapper' and 'com.rainfe.mapletr.bigscreen.module.system.mapper.SysMailJobMapper' mapperInterface. Bean already defined with the same name! 23:11:53.489 [main] WARN o.m.s.mapper.ClassPathMapperScanner - Skipping MapperFactoryBean with name 'sysPermitsDataMapper' and 'com.rainfe.mapletr.bigscreen.module.system.mapper.SysPermitsDataMapper' mapperInterface. Bean already defined with the same name! 23:11:53.490 [main] WARN o.m.s.mapper.ClassPathMapperScanner - Skipping MapperFactoryBean with name 'sysPermitsMapper' and 'com.rainfe.mapletr.bigscreen.module.system.mapper.SysPermitsMapper' mapperInterface. Bean already defined with the same name! 23:11:53.490 [main] WARN o.m.s.mapper.ClassPathMapperScanner - Skipping MapperFactoryBean with name 'sysPermitsUserMapper' and 'com.rainfe.mapletr.bigscreen.module.system.mapper.SysPermitsUserMapper' mapperInterface. Bean already defined with the same name! 23:11:53.490 [main] WARN o.m.s.mapper.ClassPathMapperScanner - Skipping MapperFactoryBean with name 'sysRoleAccessMapper' and 'com.rainfe.mapletr.bigscreen.module.system.mapper.SysRoleAccessMapper' mapperInterface. Bean already defined with the same name! 23:11:53.490 [main] WARN o.m.s.mapper.ClassPathMapperScanner - Skipping MapperFactoryBean with name 'sysRoleMapper' and 'com.rainfe.mapletr.bigscreen.module.system.mapper.SysRoleMapper' mapperInterface. Bean already defined with the same name! 23:11:53.490 [main] WARN o.m.s.mapper.ClassPathMapperScanner - Skipping MapperFactoryBean with name 'sysUserMapper' and 'com.rainfe.mapletr.bigscreen.module.system.mapper.SysUserMapper' mapperInterface. Bean already defined with the same name! 23:11:53.490 [main] WARN o.m.s.mapper.ClassPathMapperScanner - Skipping MapperFactoryBean with name 'dmtAccountMapper' and 'com.rainfe.mapletr.account.mapper.DmtAccountMapper' mapperInterface. Bean already defined with the same name! 23:11:53.490 [main] WARN o.m.s.mapper.ClassPathMapperScanner - Skipping MapperFactoryBean with name 'dmtDataSourceMapper' and 'com.rainfe.mapletr.account.mapper.DmtDataSourceMapper' mapperInterface. Bean already defined with the same name! 23:11:53.490 [main] WARN o.m.s.mapper.ClassPathMapperScanner - Skipping MapperFactoryBean with name 'dmtLogicModelDiagramMapper' and 'com.rainfe.mapletr.account.mapper.DmtLogicModelDiagramMapper' mapperInterface. Bean already defined with the same name! 23:11:53.490 [main] WARN o.m.s.mapper.ClassPathMapperScanner - Skipping MapperFactoryBean with name 'dmtRelationLineMapper' and 'com.rainfe.mapletr.account.mapper.DmtRelationLineMapper' mapperInterface. Bean already defined with the same name! 23:11:53.490 [main] WARN o.m.s.mapper.ClassPathMapperScanner - Skipping MapperFactoryBean with name 'dmtRoleMapper' and 'com.rainfe.mapletr.account.mapper.DmtRoleMapper' mapperInterface. Bean already defined with the same name! 23:11:53.490 [main] WARN o.m.s.mapper.ClassPathMapperScanner - Skipping MapperFactoryBean with name 'dmtRoleUserMapper' and 'com.rainfe.mapletr.account.mapper.DmtRoleUserMapper' mapperInterface. Bean already defined with the same name! 23:11:53.490 [main] WARN o.m.s.mapper.ClassPathMapperScanner - Skipping MapperFactoryBean with name 'dmtUserMapper' and 'com.rainfe.mapletr.account.mapper.DmtUserMapper' mapperInterface. Bean already defined with the same name! 23:11:53.490 [main] WARN o.m.s.mapper.ClassPathMapperScanner - Skipping MapperFactoryBean with name 'testUserMapper' and 'com.rainfe.mapletr.account.mapper.TestUserMapper' mapperInterface. Bean already defined with the same name! 23:11:53.490 [main] WARN o.m.s.mapper.ClassPathMapperScanner - Skipping MapperFactoryBean with name 'dataToolMapper' and 'com.rainfe.mapletr.dmt.datatool.mapper.DataToolMapper' mapperInterface. Bean already defined with the same name! 23:11:55.999 [main] INFO c.u.j.c.EnableEncryptablePropertiesBeanFactoryPostProcessor - Post-processing PropertySource instances 23:11:56.001 [main] INFO c.u.j.EncryptablePropertySourceConverter - Skipping PropertySource configurationProperties [class org.springframework.boot.context.properties.source.ConfigurationPropertySourcesPropertySource 23:11:56.010 [main] INFO c.u.j.EncryptablePropertySourceConverter - Skipping PropertySource servletConfigInitParams [class org.springframework.core.env.PropertySource$StubPropertySource 23:11:56.010 [main] INFO c.u.j.EncryptablePropertySourceConverter - Skipping PropertySource servletContextInitParams [class org.springframework.core.env.PropertySource$StubPropertySource 23:11:56.012 [main] INFO c.u.j.EncryptablePropertySourceConverter - Converting PropertySource systemProperties [org.springframework.core.env.PropertiesPropertySource] to EncryptableMapPropertySourceWrapper 23:11:56.013 [main] INFO c.u.j.EncryptablePropertySourceConverter - Converting PropertySource systemEnvironment [org.springframework.boot.env.SystemEnvironmentPropertySourceEnvironmentPostProcessor$OriginAwareSystemEnvironmentPropertySource] to EncryptableSystemEnvironmentPropertySourceWrapper 23:11:56.013 [main] INFO c.u.j.EncryptablePropertySourceConverter - Converting PropertySource random [org.springframework.boot.env.RandomValuePropertySource] to EncryptablePropertySourceWrapper 23:11:56.013 [main] INFO c.u.j.EncryptablePropertySourceConverter - Converting PropertySource Config resource 'file [config/application-activiti.properties]' via location 'config/application.properties' [org.springframework.boot.env.OriginTrackedMapPropertySource] to EncryptableMapPropertySourceWrapper 23:11:56.013 [main] INFO c.u.j.EncryptablePropertySourceConverter - Converting PropertySource Config resource 'file [config/application-db.properties]' via location 'config/application.properties' [org.springframework.boot.env.OriginTrackedMapPropertySource] to EncryptableMapPropertySourceWrapper 23:11:56.014 [main] INFO c.u.j.EncryptablePropertySourceConverter - Converting PropertySource Config resource 'file [config/application.properties]' via location 'config/application.properties' [org.springframework.boot.env.OriginTrackedMapPropertySource] to EncryptableMapPropertySourceWrapper 23:11:56.014 [main] INFO c.u.j.EncryptablePropertySourceConverter - Converting PropertySource class path resource [conf/rest-jackson-configuration.properties] [org.springframework.core.env.CompositePropertySource] to EncryptableEnumerablePropertySourceWrapper 23:11:56.014 [main] INFO c.u.j.EncryptablePropertySourceConverter - Converting PropertySource class path resource [config/ureport.properties] [org.springframework.core.io.support.ResourcePropertySource] to EncryptableMapPropertySourceWrapper 23:11:58.811 [main] INFO c.u.j.f.DefaultLazyPropertyFilter - Property Filter custom Bean not found with name 'encryptablePropertyFilter'. Initializing Default Property Filter 23:11:58.836 [main] INFO c.u.j.r.DefaultLazyPropertyResolver - Property Resolver custom Bean not found with name 'encryptablePropertyResolver'. Initializing Default Property Resolver 23:11:58.844 [main] INFO c.u.j.d.DefaultLazyPropertyDetector - Property Detector custom Bean not found with name 'encryptablePropertyDetector'. Initializing Default Property Detector 23:12:05.330 [main] WARN c.alibaba.druid.pool.DruidDataSource - removeAbandoned is true, not use in production. 23:12:06.572 [main] INFO c.alibaba.druid.pool.DruidDataSource - {dataSource-1} inited 23:12:08.365 [main] WARN org.hibernate.mapping.RootClass - HHH000038: Composite-id class does not override equals(): com.rainfe.mapletr.dps.entity.OrganizationPortalId 23:12:08.366 [main] WARN org.hibernate.mapping.RootClass - HHH000039: Composite-id class does not override hashCode(): com.rainfe.mapletr.dps.entity.OrganizationPortalId 23:12:08.369 [main] WARN org.hibernate.mapping.RootClass - HHH000038: Composite-id class does not override equals(): com.rainfe.mapletr.dps.entity.UserOrgNameId 23:12:08.369 [main] WARN org.hibernate.mapping.RootClass - HHH000039: Composite-id class does not override hashCode(): com.rainfe.mapletr.dps.entity.UserOrgNameId 23:12:08.371 [main] WARN org.hibernate.mapping.RootClass - HHH000038: Composite-id class does not override equals(): com.rainfe.mapletr.dps.entity.PersonalGroupUserId 23:12:08.371 [main] WARN org.hibernate.mapping.RootClass - HHH000039: Composite-id class does not override hashCode(): com.rainfe.mapletr.dps.entity.PersonalGroupUserId 23:12:08.375 [main] WARN org.hibernate.mapping.RootClass - HHH000038: Composite-id class does not override equals(): com.rainfe.mapletr.dps.entity.UserOrganizationId 23:12:08.376 [main] WARN org.hibernate.mapping.RootClass - HHH000039: Composite-id class does not override hashCode(): com.rainfe.mapletr.dps.entity.UserOrganizationId 23:12:08.377 [main] WARN org.hibernate.mapping.RootClass - HHH000038: Composite-id class does not override equals(): com.rainfe.mapletr.dps.entity.UserRoleId 23:12:08.377 [main] WARN org.hibernate.mapping.RootClass - HHH000039: Composite-id class does not override hashCode(): com.rainfe.mapletr.dps.entity.UserRoleId 23:12:08.379 [main] WARN org.hibernate.mapping.RootClass - HHH000038: Composite-id class does not override equals(): com.rainfe.mapletr.dps.entity.UserOrgNameId 23:12:08.379 [main] WARN org.hibernate.mapping.RootClass - HHH000039: Composite-id class does not override hashCode(): com.rainfe.mapletr.dps.entity.UserOrgNameId 23:12:08.381 [main] WARN org.hibernate.mapping.RootClass - HHH000038: Composite-id class does not override equals(): com.rainfe.mapletr.dps.entity.UserOrgNameId 23:12:08.381 [main] WARN org.hibernate.mapping.RootClass - HHH000039: Composite-id class does not override hashCode(): com.rainfe.mapletr.dps.entity.UserOrgNameId 23:12:22.305 [main] INFO o.a.coyote.http11.Http11NioProtocol - Initializing ProtocolHandler ["http-nio-2000"] 23:12:22.306 [main] INFO o.a.catalina.core.StandardService - Starting service [Tomcat] 23:12:22.307 [main] INFO o.a.catalina.core.StandardEngine - Starting Servlet engine: [Apache Tomcat/9.0.41] 23:12:22.574 [main] INFO o.a.c.c.C.[Tomcat].[localhost].[/] - Initializing Spring embedded WebApplicationContext _ _ |_ _ _|_. ___ _ | _ | | |\/|_)(_| | |_\ |_)||_|_\ / | 3.5.3.2 23:12:34.679 [main] WARN org.hibernate.mapping.RootClass - HHH000038: Composite-id class does not override equals(): com.rainfe.mapletr.dps.entity.OrganizationPortalId 23:12:34.680 [main] WARN org.hibernate.mapping.RootClass - HHH000039: Composite-id class does not override hashCode(): com.rainfe.mapletr.dps.entity.OrganizationPortalId 23:12:34.682 [main] WARN org.hibernate.mapping.RootClass - HHH000038: Composite-id class does not override equals(): com.rainfe.mapletr.dps.entity.UserOrgNameId 23:12:34.683 [main] WARN org.hibernate.mapping.RootClass - HHH000039: Composite-id class does not override hashCode(): com.rainfe.mapletr.dps.entity.UserOrgNameId 23:12:34.684 [main] WARN org.hibernate.mapping.RootClass - HHH000038: Composite-id class does not override equals(): com.rainfe.mapletr.dps.entity.PersonalGroupUserId 23:12:34.685 [main] WARN org.hibernate.mapping.RootClass - HHH000039: Composite-id class does not override hashCode(): com.rainfe.mapletr.dps.entity.PersonalGroupUserId 23:12:34.688 [main] WARN org.hibernate.mapping.RootClass - HHH000038: Composite-id class does not override equals(): com.rainfe.mapletr.dps.entity.UserOrganizationId 23:12:34.688 [main] WARN org.hibernate.mapping.RootClass - HHH000039: Composite-id class does not override hashCode(): com.rainfe.mapletr.dps.entity.UserOrganizationId 23:12:34.689 [main] WARN org.hibernate.mapping.RootClass - HHH000038: Composite-id class does not override equals(): com.rainfe.mapletr.dps.entity.UserRoleId 23:12:34.689 [main] WARN org.hibernate.mapping.RootClass - HHH000039: Composite-id class does not override hashCode(): com.rainfe.mapletr.dps.entity.UserRoleId 23:12:34.690 [main] WARN org.hibernate.mapping.RootClass - HHH000038: Composite-id class does not override equals(): com.rainfe.mapletr.dps.entity.UserOrgNameId 23:12:34.691 [main] WARN org.hibernate.mapping.RootClass - HHH000039: Composite-id class does not override hashCode(): com.rainfe.mapletr.dps.entity.UserOrgNameId 23:12:34.692 [main] WARN org.hibernate.mapping.RootClass - HHH000038: Composite-id class does not override equals(): com.rainfe.mapletr.dps.entity.UserOrgNameId 23:12:34.692 [main] WARN org.hibernate.mapping.RootClass - HHH000039: Composite-id class does not override hashCode(): com.rainfe.mapletr.dps.entity.UserOrgNameId 23:13:00.251 [main] WARN o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'initServer': Invocation of init method failed; nested exception is java.lang.UnsatisfiedLinkError: no jniavutil in java.library.path 23:13:00.365 [main] INFO c.alibaba.druid.pool.DruidDataSource - {dataSource-1} closing ... 23:13:00.386 [main] INFO c.alibaba.druid.pool.DruidDataSource - {dataSource-1} closed 23:13:00.390 [main] INFO o.a.catalina.core.StandardService - Stopping service [Tomcat] 23:13:00.396 [main] WARN o.a.c.loader.WebappClassLoaderBase - The web application [ROOT] appears to have started a thread named [Thread-9] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread: java.lang.Thread.sleep(Native Method) com.rainfe.mapletr.dps.service.impl.OnlineUserServiceImpl.lambda$static$0(OnlineUserServiceImpl.java:76) com.rainfe.mapletr.dps.service.impl.OnlineUserServiceImpl$$Lambda$894/455706711.run(Unknown Source) java.lang.Thread.run(Thread.java:748) 23:13:00.484 [main] ERROR o.s.boot.SpringApplication - Application run failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'initServer': Invocation of init method failed; nested exception is java.lang.UnsatisfiedLinkError: no jniavutil in java.library.path at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:160) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:429) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1780) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:609) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:531) at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:944) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:923) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:588) at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:144) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:767) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:426) at org.springframework.boot.SpringApplication.run(SpringApplication.java:326) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1311) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1300) at com.rainfe.WebApplication.main(WebApplication.java:25) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49) at org.springframework.boot.loader.Launcher.launch(Launcher.java:107) at org.springframework.boot.loader.Launcher.launch(Launcher.java:58) at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88) Caused by: java.lang.UnsatisfiedLinkError: no jniavutil in java.library.path at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1860) at java.lang.Runtime.loadLibrary0(Runtime.java:871) at java.lang.System.loadLibrary(System.java:1124) at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:1543) at org.bytedeco.javacpp.Loader.load(Loader.java:1192) at org.bytedeco.javacpp.Loader.load(Loader.java:1042) at org.bytedeco.ffmpeg.global.avutil.<clinit>(avutil.java:12) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:348) at org.bytedeco.javacpp.Loader.load(Loader.java:1109) at org.bytedeco.javacpp.Loader.load(Loader.java:1058) at com.rainfe.mapletr.bigscreen.module.easymedia.init.InitServer.loadFFmpeg(InitServer.java:125) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:389) at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:333) at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:157) ... 27 common frames omitted 报错怎么解决
11-12
【CNN-GRU-Attention】基于卷积神经网络和门控循环单元网络结合注意力机制的多变量回归预测研究(Matlab代码实现)内容概要:本文介绍了基于卷积神经网络(CNN)、门控循环单元网络(GRU)注意力机制(Attention)相结合的多变量回归预测模型研究,重点利用Matlab实现该深度学习模型的构建仿真。该模型通过CNN提取输入数据的局部特征,利用GRU捕捉时间序列的长期依赖关系,并引入注意力机制增强关键时间步的权重,从而提升多变量时间序列回归预测的精度鲁棒性。文中涵盖了模型架构设计、训练流程、参数调优及实际案例验证,适用于复杂非线性系统的预测任务。; 适合人群:具备一定机器学习深度学习基础,熟悉Matlab编程环境,从事科研或工程应用的研究生、科研人员及算法工程师,尤其适合关注时间序列预测、能源预测、智能优化等方向的技术人员。; 使用场景及目标:①应用于风电功率预测、负荷预测、交通流量预测等多变量时间序列回归任务;②帮助读者掌握CNN-GRU-Attention混合模型的设计思路Matlab实现方法;③为学术研究、毕业论文或项目开发提供可复现的代码参考和技术支持。; 阅读建议:建议读者结合Matlab代码逐模块理解模型实现细节,重点关注数据预处理、网络结构搭建注意力机制的嵌入方式,并通过调整超参数和更换数据集进行实验验证,以深化对模型性能影响因素的理解。
下载前必看:https://pan.quark.cn/s/da7147b0e738 《商品采购管理系统详解》商品采购管理系统是一款依托数据库技术,为中小企业量身定制的高效且易于操作的应用软件。 该系统借助VC++编程语言完成开发,致力于改进采购流程,增强企业管理效能,尤其适合初学者开展学习实践活动。 在此之后,我们将详细剖析该系统的各项核心功能及其实现机制。 1. **VC++ 开发环境**: VC++是微软公司推出的集成开发平台,支持C++编程,具备卓越的Windows应用程序开发性能。 在该系统中,VC++作为核心编程语言,负责实现用户界面、业务逻辑以及数据处理等关键功能。 2. **数据库基础**: 商品采购管理系统的核心在于数据库管理,常用的如SQL Server或MySQL等数据库系统。 数据库用于保存商品信息、供应商资料、采购订单等核心数据。 借助SQL(结构化查询语言)进行数据的增加、删除、修改和查询操作,确保信息的精确性和即时性。 3. **商品管理**: 系统内含商品信息管理模块,涵盖商品名称、规格、价格、库存等关键字段。 借助界面,用户能够便捷地录入、调整和查询商品信息,实现库存的动态调控。 4. **供应商管理**: 供应商信息在采购环节中占据重要地位,系统提供供应商注册、联系方式记录、信用评价等功能,助力企业构建稳固的供应链体系。 5. **采购订单管理**: 采购订单是采购流程的关键环节,系统支持订单的生成、审批、执行和追踪。 通过自动化处理,减少人为失误,提升工作效率。 6. **报表分析**: 系统具备数据分析能力,能够生成采购报表、库存报表等,帮助企业掌握采购成本、库存周转率等关键数据,为决策提供支持。 7. **用户界面设计**: 依托VC++的MF...
【DC-AC】使用了H桥MOSFET进行开关,电感器作为滤波器,R和C作为负载目标是产生150V的双极输出和4安培(双极)的电流(Simulink仿真实现)内容概要:本文档围绕一个基于Simulink的电力电子系统仿真项目展开,重点介绍了一种采用H桥MOSFET进行开关操作的DC-AC逆变电路设计,结合电感器作为滤波元件,R和C构成负载,旨在实现150V双极性输出电压和4A双极性电流的仿真目标。文中详细描述了系统结构、关键器件选型及控制策略,展示了通过Simulink平台完成建模仿真的全过程,并强调了参数调整波形分析的重要性,以确保输出符合设计要求。此外,文档还提及该仿真模型在电力变换、新能源并网等领域的应用潜力。; 适合人群:具备电力电子基础知识和Simulink仿真经验的高校学生、科研人员及从事电力系统、新能源技术等相关领域的工程技术人员;熟悉电路拓扑基本控制理论的初级至中级研究人员。; 使用场景及目标:①用于教学演示H桥逆变器的工作原理滤波设计;②支撑科研项目中对双极性电源系统的性能验证;③为实际工程中DC-AC转换器的设计优化提供仿真依据和技术参考;④帮助理解MOSFET开关行为、LC滤波机制及负载响应特性。; 阅读建议:建议读者结合Simulink模型文件同步操作,重点关注H桥驱动信号生成、电感电容参数选取及输出波形的傅里叶分析,建议在仿真过程中逐步调试开关频率占空比,观察其对输出电压电流的影响,以深化对逆变系统动态特性的理解。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值