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
【电能质量扰动】基于ML和DWT的电能质量扰动分类方法研究(Matlab实现)内容概要:本文研究了一种基于机器学习(ML)和离散小波变换(DWT)的电能质量扰动分类方法,并提供了Matlab实现方案。首先利用DWT对电能质量信号进行多尺度分解,提取信号的时频域特征,有效捕捉电压暂降、暂升、中断、谐波、闪变等常见扰动的关键信息;随后结合机器学习分类器(如SVM、BP神经网络等)对提取的特征进行训练分类,实现对不同类型扰动的自动识别准确区分。该方法充分发挥DWT在信号去噪特征提取方面的优势,结合ML强大的模式识别能力,提升了分类精度鲁棒性,具有较强的实用价值。; 适合人群:电气工程、自动化、电力系统及其自动化等相关专业的研究生、科研人员及从事电能质量监测分析的工程技术人员;具备一定的信号处理基础和Matlab编程能力者更佳。; 使用场景及目标:①应用于智能电网中的电能质量在线监测系统,实现扰动类型的自动识别;②作为高校或科研机构在信号处理、模式识别、电力系统分析等课程的教学案例或科研实验平台;③目标是提高电能质量扰动分类的准确性效率,为后续的电能治理设备保护提供决策依据。; 阅读建议:建议读者结合Matlab代码深入理解DWT的实现过程特征提取步骤,重点关注小波基选择、分解层数设定及特征向量构造对分类性能的影响,并尝试对比不同机器学习模型的分类效果,以全面掌握该方法的核心技术要点。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值