精华内容
下载资源
问答
  • 报错java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.String解决踩坑
    千次阅读
    2021-06-09 17:42:33

    java.lang.ClassCaption: java.lang.Long cannot be cast to java.lang.String

    问题背景

    service传参调用mapper,报错:

    [09 17:56:54,707 DEBUG] [http-nio-8081-exec-9] handler.SimpleMappingExceptionResolver - Resolving to view 'WEB-INF/500' for exception of type [java.lang.ClassCastException], based on exception mapping [java.lang.Throwable]
    [09 17:56:54,707 DEBUG] [http-nio-8081-exec-9] handler.SimpleMappingExceptionResolver - Exposing Exception as model attribute 'exception'
    [09 17:56:54,707 DEBUG] [http-nio-8081-exec-9] servlet.DispatcherServlet - Handler execution resulted in exception - forwarding to resolved error view: ModelAndView: reference to view with name 'WEB-INF/500'; model is {exception=java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.String}
    java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.String

    //加判断,如果已经使用,无法删除
    Map<String, String> template = detectionTemplateMapper.queryTypeById(id);
    //查询异常工单是否使用
    if(adminOrderMapper.findCountByDetection(template.get("id").toString(),template.get("detectionType"))>0){
        return 0;
    }
    
    <select id="queryTypeById" resultType="java.util.HashMap">
        SELECT id,detectionType,ordernum,isSingle,isMainType,remark from work_detection_template where id=#{0}
    </select>
    

    问题分析

    因为查询的id数据库是int类型,返回结果为Long类型,所以想着toString即可,结果还是报错,改为String.valueOf()后不报错了。

    问题总结

    转换字符串,尽量使用valueOf()方法吧

    /**
     * Returns the string representation of the {@code Object} argument.
     *
     * @param   obj   an {@code Object}.
     * @return  if the argument is {@code null}, then a string equal to
     *          {@code "null"}; otherwise, the value of
     *          {@code obj.toString()} is returned.
     * @see     java.lang.Object#toString()
     */
    public static String valueOf(Object obj) {
        return (obj == null) ? "null" : obj.toString();
    }

     

     

     

    更多相关内容
  • Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module ...

    Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not “opens java.lang” to unnamed module @1ba9117e


    在将一个 JDK 8 的项目转移到 JDK 11 的运行环境中时,遇到了如下的问题:

    Caused by: java.lang.IllegalStateException: Failed to create adaptive instance: java.lang.IllegalStateException: Can't create adaptive extension interface org.apache.dubbo.rpc.Protocol, cause: Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @1ba9117e
    	at org.apache.dubbo.common.extension.ExtensionLoader.getAdaptiveExtension(ExtensionLoader.java:592)
    	at org.apache.dubbo.config.ServiceConfig.<clinit>(ServiceConfig.java:118)
    	... 31 common frames omitted
    Caused by: java.lang.IllegalStateException: Can't create adaptive extension interface org.apache.dubbo.rpc.Protocol, cause: Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @1ba9117e
    	at org.apache.dubbo.common.extension.ExtensionLoader.createAdaptiveExtension(ExtensionLoader.java:1021)
    	at org.apache.dubbo.common.extension.ExtensionLoader.getAdaptiveExtension(ExtensionLoader.java:588)
    	... 32 common frames omitted
    
    

    这是由于 JDK 8 中有关反射相关的功能自从 JDK 9 开始就已经被限制了,为了兼容原先的版本,需要在运行项目时添加 --add-opens java.base/java.lang=ALL-UNNAMED 选项来开启这种默认不被允许的行为。


    如果是通过 IDEA 来运行项目,那么可以在 “Edit Configurations” 中 ——> “VM options” 输入框中输入该选项来完成,最终结果如下图所示:
    在这里插入图片描述

    除了添加选项启动选项之外,由于原本的项目是在 JDK 8 的环境中运行的,此时需要将运行的 JDK 转变为 JDK 11,具体做法(仅针对 Maven 项目):将父 pom.xml 文件中的 <java.version> 标签中的 java 版本修改为需要运行的版本,具体如下所示:

    <properties>
    	<java.version>11</java.version>
    </properties>
    
    展开全文
  • 745) Caused by: java.lang.IllegalArgumentException: Can not set java.lang.String field nl.marcusink.mmo.server.database.table.User.username to java.lang.String at sun.reflect.UnsafeFieldAccessorImpl....

    我目前正在开发带有套接字服务器的小型MMO应用程序.我使用的数据库是PostgreSQL,而我使用的是Hibernate ORM.

    当请求一个用户拥有的所有头像时,我偶然发现了一个例外.

    我参与了3个班级的学习,分别是:

    > GameServerClient

    >数据库

    >数据库查询

    当用户(客户端应用程序)通过套接字向服务器发送请求时,将调用一个方法,该方法应返回所有头像的JsonString.

    但是,使用来自UserOwnsAvatar的HQL查询(其中user =:username)并将结果放入UserOwnsAvatar对象的ArrayList中,它将返回无法设置的java.lang.String字段nl.marcusink.mmo.server.database.table.User .username到java.lang.String

    完整的stackTrace是:

    org.hibernate.property.access.spi.PropertyAccessException: Error accessing field [private java.lang.String nl.marcusink.mmo.server.database.table.User.username] by reflection for persistent property [nl.marcusink.mmo.server.database.table.User#username] : Mjollnir94

    at org.hibernate.property.access.spi.GetterFieldImpl.get(GetterFieldImpl.java:43)

    at org.hibernate.tuple.entity.AbstractEntityTuplizer.getIdentifier(AbstractEntityTuplizer.java:223)

    at org.hibernate.persister.entity.AbstractEntityPersister.getIdentifier(AbstractEntityPersister.java:4594)

    at org.hibernate.type.EntityType.toLoggableString(EntityType.java:505)

    at org.hibernate.internal.util.EntityPrinter.toString(EntityPrinter.java:87)

    at org.hibernate.engine.spi.QueryParameters.traceParameters(QueryParameters.java:281)

    at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:194)

    at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1268)

    at org.hibernate.internal.QueryImpl.list(QueryImpl.java:87)

    at nl.marcusink.mmo.server.database.Database$Queries.avatarsRequest(Database.java:134)

    at nl.marcusink.mmo.server.connection.GameServerClient.run(GameServerClient.java:91)

    at java.lang.Thread.run(Thread.java:745)

    Caused by: java.lang.IllegalArgumentException: Can not set java.lang.String field nl.marcusink.mmo.server.database.table.User.username to java.lang.String

    at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:167)

    at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:171)

    at sun.reflect.UnsafeFieldAccessorImpl.ensureObj(UnsafeFieldAccessorImpl.java:58)

    at sun.reflect.UnsafeObjectFieldAccessorImpl.get(UnsafeObjectFieldAccessorImpl.java:36)

    at java.lang.reflect.Field.get(Field.java:393)

    at org.hibernate.property.access.spi.GetterFieldImpl.get(GetterFieldImpl.java:39)

    ... 11 more

    查询代码为:

    Query query = session.createQuery("from UserOwnsAvatar where user = :username");

    query.setParameter("username", username);

    ArrayList ownedAvatars = (ArrayList) query.list();

    最后一行是错误的原因,有什么想法吗?

    编辑

    @Id

    @ManyToOne(targetEntity = User.class)

    @JoinColumn(name = "username", nullable = false)

    private User user;

    @Id

    @OneToOne(targetEntity = Avatar.class)

    @JoinColumn(name = "avatar", nullable = false, unique = true)

    private Avatar avatar;

    这里的用户名等于User对象的用户名,即:

    @Id

    @Column(name = "username", unique = true, nullable = false)

    private String username;

    解决方法:

    您将必须设置完整(或仅具有相关字段的对象),而不是该对象的一个​​特定值.

    我了解的是您正在尝试在设置参数时设置字符串,但是列的类型为User. Hibernate试图在String上调用getUsername方法,这就是错误的原因.

    因此,将您的代码更改为如下所示:

    User user = getSomeUser();

    Query query = session.createQuery("from UserOwnsAvatar where user.username = :username");

    query.setParameter("username", user);

    标签:sockets,server,hibernate,java

    来源: https://codeday.me/bug/20191119/2036948.html

    展开全文
  • java.lang.RuntimeException: java.lang.reflect.InvocationTargetException at tk.mybatis.spring.mapper.SpringBootBindUtilSpringBoot2Bind.bind(SpringBootBindUtil.java:129) [mapper−spring−boot−...

    报错信息
    java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at tk.mybatis.spring.mapper.SpringBootBindUtil S p r i n g B o o t 2 B i n d . b i n d ( S p r i n g B o o t B i n d U t i l . j a v a : 129 )   [ m a p p e r − s p r i n g − b o o t − a u t o c o n f i g u r e − 1.2.3. j a r : n a ] a t t k . m y b a t i s . s p r i n g . m a p p e r . S p r i n g B o o t B i n d U t i l . b i n d ( S p r i n g B o o t B i n d U t i l . j a v a : 58 )   [ m a p p e r − s p r i n g − b o o t − a u t o c o n f i g u r e − 1.2.3. j a r : n a ] a t t k . m y b a t i s . s p r i n g . m a p p e r . C l a s s P a t h M a p p e r S c a n n e r . s e t M a p p e r P r o p e r t i e s ( C l a s s P a t h M a p p e r S c a n n e r . j a v a : 48 )   [ m a p p e r − s p r i n g − b o o t − a u t o c o n f i g u r e − 1.2.3. j a r : n a ] a t t k . m y b a t i s . s p r i n g . a n n o t a t i o n . M a p p e r S c a n n e r R e g i s t r a r . r e g i s t e r B e a n D e f i n i t i o n s ( M a p p e r S c a n n e r R e g i s t r a r . j a v a : 33 )   [ m a p p e r − s p r i n g − b o o t − a u t o c o n f i g u r e − 1.2.3. j a r : n a ] a t o r g . s p r i n g f r a m e w o r k . c o n t e x t . a n n o t a t i o n . C o n f i g u r a t i o n C l a s s B e a n D e f i n i t i o n R e a d e r . l a m b d a SpringBoot2Bind.bind(SpringBootBindUtil.java:129) ~[mapper-spring-boot-autoconfigure-1.2.3.jar:na] at tk.mybatis.spring.mapper.SpringBootBindUtil.bind(SpringBootBindUtil.java:58) ~[mapper-spring-boot-autoconfigure-1.2.3.jar:na] at tk.mybatis.spring.mapper.ClassPathMapperScanner.setMapperProperties(ClassPathMapperScanner.java:48) ~[mapper-spring-boot-autoconfigure-1.2.3.jar:na] at tk.mybatis.spring.annotation.MapperScannerRegistrar.registerBeanDefinitions(MapperScannerRegistrar.java:33) ~[mapper-spring-boot-autoconfigure-1.2.3.jar:na] at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.lambda SpringBoot2Bind.bind(SpringBootBindUtil.java:129) [mapperspringbootautoconfigure1.2.3.jar:na]attk.mybatis.spring.mapper.SpringBootBindUtil.bind(SpringBootBindUtil.java:58) [mapperspringbootautoconfigure1.2.3.jar:na]attk.mybatis.spring.mapper.ClassPathMapperScanner.setMapperProperties(ClassPathMapperScanner.java:48) [mapperspringbootautoconfigure1.2.3.jar:na]attk.mybatis.spring.annotation.MapperScannerRegistrar.registerBeanDefinitions(MapperScannerRegistrar.java:33) [mapperspringbootautoconfigure1.2.3.jar:na]atorg.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.lambdaloadBeanDefinitionsFromRegistrars 1 ( C o n f i g u r a t i o n C l a s s B e a n D e f i n i t i o n R e a d e r . j a v a : 363 )   [ s p r i n g − c o n t e x t − 5.1.15. R E L E A S E . j a r : 5.1.15. R E L E A S E ] a t j a v a . u t i l . L i n k e d H a s h M a p . f o r E a c h ( L i n k e d H a s h M a p . j a v a : 684 )   [ n a : 1.8. 0 1 31 ] a t o r g . s p r i n g f r a m e w o r k . c o n t e x t . a n n o t a t i o n . C o n f i g u r a t i o n C l a s s B e a n D e f i n i t i o n R e a d e r . l o a d B e a n D e f i n i t i o n s F r o m R e g i s t r a r s ( C o n f i g u r a t i o n C l a s s B e a n D e f i n i t i o n R e a d e r . j a v a : 362 )   [ s p r i n g − c o n t e x t − 5.1.15. R E L E A S E . j a r : 5.1.15. R E L E A S E ] a t o r g . s p r i n g f r a m e w o r k . c o n t e x t . a n n o t a t i o n . C o n f i g u r a t i o n C l a s s B e a n D e f i n i t i o n R e a d e r . l o a d B e a n D e f i n i t i o n s F o r C o n f i g u r a t i o n C l a s s ( C o n f i g u r a t i o n C l a s s B e a n D e f i n i t i o n R e a d e r . j a v a : 145 )   [ s p r i n g − c o n t e x t − 5.1.15. R E L E A S E . j a r : 5.1.15. R E L E A S E ] a t o r g . s p r i n g f r a m e w o r k . c o n t e x t . a n n o t a t i o n . C o n f i g u r a t i o n C l a s s B e a n D e f i n i t i o n R e a d e r . l o a d B e a n D e f i n i t i o n s ( C o n f i g u r a t i o n C l a s s B e a n D e f i n i t i o n R e a d e r . j a v a : 117 )   [ s p r i n g − c o n t e x t − 5.1.15. R E L E A S E . j a r : 5.1.15. R E L E A S E ] a t o r g . s p r i n g f r a m e w o r k . c o n t e x t . a n n o t a t i o n . C o n f i g u r a t i o n C l a s s P o s t P r o c e s s o r . p r o c e s s C o n f i g B e a n D e f i n i t i o n s ( C o n f i g u r a t i o n C l a s s P o s t P r o c e s s o r . j a v a : 327 )   [ s p r i n g − c o n t e x t − 5.1.15. R E L E A S E . j a r : 5.1.15. R E L E A S E ] a t o r g . s p r i n g f r a m e w o r k . c o n t e x t . a n n o t a t i o n . C o n f i g u r a t i o n C l a s s P o s t P r o c e s s o r . p o s t P r o c e s s B e a n D e f i n i t i o n R e g i s t r y ( C o n f i g u r a t i o n C l a s s P o s t P r o c e s s o r . j a v a : 232 )   [ s p r i n g − c o n t e x t − 5.1.15. R E L E A S E . j a r : 5.1.15. R E L E A S E ] a t o r g . s p r i n g f r a m e w o r k . c o n t e x t . s u p p o r t . P o s t P r o c e s s o r R e g i s t r a t i o n D e l e g a t e . i n v o k e B e a n D e f i n i t i o n R e g i s t r y P o s t P r o c e s s o r s ( P o s t P r o c e s s o r R e g i s t r a t i o n D e l e g a t e . j a v a : 275 )   [ s p r i n g − c o n t e x t − 5.1.15. R E L E A S E . j a r : 5.1.15. R E L E A S E ] a t o r g . s p r i n g f r a m e w o r k . c o n t e x t . s u p p o r t . P o s t P r o c e s s o r R e g i s t r a t i o n D e l e g a t e . i n v o k e B e a n F a c t o r y P o s t P r o c e s s o r s ( P o s t P r o c e s s o r R e g i s t r a t i o n D e l e g a t e . j a v a : 95 )   [ s p r i n g − c o n t e x t − 5.1.15. R E L E A S E . j a r : 5.1.15. R E L E A S E ] a t o r g . s p r i n g f r a m e w o r k . c o n t e x t . s u p p o r t . A b s t r a c t A p p l i c a t i o n C o n t e x t . i n v o k e B e a n F a c t o r y P o s t P r o c e s s o r s ( A b s t r a c t A p p l i c a t i o n C o n t e x t . j a v a : 705 )   [ s p r i n g − c o n t e x t − 5.1.15. R E L E A S E . j a r : 5.1.15. R E L E A S E ] a t o r g . s p r i n g f r a m e w o r k . c o n t e x t . s u p p o r t . A b s t r a c t A p p l i c a t i o n C o n t e x t . r e f r e s h ( A b s t r a c t A p p l i c a t i o n C o n t e x t . j a v a : 531 )   [ s p r i n g − c o n t e x t − 5.1.15. R E L E A S E . j a r : 5.1.15. R E L E A S E ] a t o r g . s p r i n g f r a m e w o r k . b o o t . w e b . s e r v l e t . c o n t e x t . S e r v l e t W e b S e r v e r A p p l i c a t i o n C o n t e x t . r e f r e s h ( S e r v l e t W e b S e r v e r A p p l i c a t i o n C o n t e x t . j a v a : 141 )   [ s p r i n g − b o o t − 2.1.14. R E L E A S E . j a r : 2.1.14. R E L E A S E ] a t o r g . s p r i n g f r a m e w o r k . b o o t . S p r i n g A p p l i c a t i o n . r e f r e s h ( S p r i n g A p p l i c a t i o n . j a v a : 744 ) [ s p r i n g − b o o t − 2.1.14. R E L E A S E . j a r : 2.1.14. R E L E A S E ] a t o r g . s p r i n g f r a m e w o r k . b o o t . S p r i n g A p p l i c a t i o n . r e f r e s h C o n t e x t ( S p r i n g A p p l i c a t i o n . j a v a : 391 ) [ s p r i n g − b o o t − 2.1.14. R E L E A S E . j a r : 2.1.14. R E L E A S E ] a t o r g . s p r i n g f r a m e w o r k . b o o t . S p r i n g A p p l i c a t i o n . r u n ( S p r i n g A p p l i c a t i o n . j a v a : 312 ) [ s p r i n g − b o o t − 2.1.14. R E L E A S E . j a r : 2.1.14. R E L E A S E ] a t o r g . s p r i n g f r a m e w o r k . b o o t . S p r i n g A p p l i c a t i o n . r u n ( S p r i n g A p p l i c a t i o n . j a v a : 1215 ) [ s p r i n g − b o o t − 2.1.14. R E L E A S E . j a r : 2.1.14. R E L E A S E ] a t o r g . s p r i n g f r a m e w o r k . b o o t . S p r i n g A p p l i c a t i o n . r u n ( S p r i n g A p p l i c a t i o n . j a v a : 1204 ) [ s p r i n g − b o o t − 2.1.14. R E L E A S E . j a r : 2.1.14. R E L E A S E ] a t c o m . t a n g s i r . u s e r . T a n g U s e r A p p l i c a t i o n . m a i n ( T a n g U s e r A p p l i c a t i o n . j a v a : 12 ) [ c l a s s e s / : n a ] C a u s e d b y : j a v a . l a n g . r e f l e c t . I n v o c a t i o n T a r g e t E x c e p t i o n : n u l l a t s u n . r e f l e c t . N a t i v e M e t h o d A c c e s s o r I m p l . i n v o k e 0 ( N a t i v e M e t h o d )   [ n a : 1.8. 0 1 31 ] a t s u n . r e f l e c t . N a t i v e M e t h o d A c c e s s o r I m p l . i n v o k e ( N a t i v e M e t h o d A c c e s s o r I m p l . j a v a : 62 )   [ n a : 1.8. 0 1 31 ] a t s u n . r e f l e c t . D e l e g a t i n g M e t h o d A c c e s s o r I m p l . i n v o k e ( D e l e g a t i n g M e t h o d A c c e s s o r I m p l . j a v a : 43 )   [ n a : 1.8. 0 1 31 ] a t j a v a . l a n g . r e f l e c t . M e t h o d . i n v o k e ( M e t h o d . j a v a : 498 )   [ n a : 1.8. 0 1 31 ] a t t k . m y b a t i s . s p r i n g . m a p p e r . S p r i n g B o o t B i n d U t i l 1(ConfigurationClassBeanDefinitionReader.java:363) ~[spring-context-5.1.15.RELEASE.jar:5.1.15.RELEASE] at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) ~[na:1.8.0_131] at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsFromRegistrars(ConfigurationClassBeanDefinitionReader.java:362) ~[spring-context-5.1.15.RELEASE.jar:5.1.15.RELEASE] at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:145) ~[spring-context-5.1.15.RELEASE.jar:5.1.15.RELEASE] at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:117) ~[spring-context-5.1.15.RELEASE.jar:5.1.15.RELEASE] at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:327) ~[spring-context-5.1.15.RELEASE.jar:5.1.15.RELEASE] at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:232) ~[spring-context-5.1.15.RELEASE.jar:5.1.15.RELEASE] at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:275) ~[spring-context-5.1.15.RELEASE.jar:5.1.15.RELEASE] at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:95) ~[spring-context-5.1.15.RELEASE.jar:5.1.15.RELEASE] at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:705) ~[spring-context-5.1.15.RELEASE.jar:5.1.15.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:531) ~[spring-context-5.1.15.RELEASE.jar:5.1.15.RELEASE] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) ~[spring-boot-2.1.14.RELEASE.jar:2.1.14.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:744) [spring-boot-2.1.14.RELEASE.jar:2.1.14.RELEASE] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:391) [spring-boot-2.1.14.RELEASE.jar:2.1.14.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:312) [spring-boot-2.1.14.RELEASE.jar:2.1.14.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) [spring-boot-2.1.14.RELEASE.jar:2.1.14.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1204) [spring-boot-2.1.14.RELEASE.jar:2.1.14.RELEASE] at com.tangsir.user.TangUserApplication.main(TangUserApplication.java:12) [classes/:na] Caused by: java.lang.reflect.InvocationTargetException: null at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_131] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_131] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_131] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_131] at tk.mybatis.spring.mapper.SpringBootBindUtil 1(ConfigurationClassBeanDefinitionReader.java:363) [springcontext5.1.15.RELEASE.jar:5.1.15.RELEASE]atjava.util.LinkedHashMap.forEach(LinkedHashMap.java:684) [na:1.8.0131]atorg.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsFromRegistrars(ConfigurationClassBeanDefinitionReader.java:362) [springcontext5.1.15.RELEASE.jar:5.1.15.RELEASE]atorg.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:145) [springcontext5.1.15.RELEASE.jar:5.1.15.RELEASE]atorg.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:117) [springcontext5.1.15.RELEASE.jar:5.1.15.RELEASE]atorg.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:327) [springcontext5.1.15.RELEASE.jar:5.1.15.RELEASE]atorg.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:232) [springcontext5.1.15.RELEASE.jar:5.1.15.RELEASE]atorg.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:275) [springcontext5.1.15.RELEASE.jar:5.1.15.RELEASE]atorg.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:95) [springcontext5.1.15.RELEASE.jar:5.1.15.RELEASE]atorg.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:705) [springcontext5.1.15.RELEASE.jar:5.1.15.RELEASE]atorg.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:531) [springcontext5.1.15.RELEASE.jar:5.1.15.RELEASE]atorg.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) [springboot2.1.14.RELEASE.jar:2.1.14.RELEASE]atorg.springframework.boot.SpringApplication.refresh(SpringApplication.java:744)[springboot2.1.14.RELEASE.jar:2.1.14.RELEASE]atorg.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:391)[springboot2.1.14.RELEASE.jar:2.1.14.RELEASE]atorg.springframework.boot.SpringApplication.run(SpringApplication.java:312)[springboot2.1.14.RELEASE.jar:2.1.14.RELEASE]atorg.springframework.boot.SpringApplication.run(SpringApplication.java:1215)[springboot2.1.14.RELEASE.jar:2.1.14.RELEASE]atorg.springframework.boot.SpringApplication.run(SpringApplication.java:1204)[springboot2.1.14.RELEASE.jar:2.1.14.RELEASE]atcom.tangsir.user.TangUserApplication.main(TangUserApplication.java:12)[classes/:na]Causedby:java.lang.reflect.InvocationTargetException:nullatsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod) [na:1.8.0131]atsun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [na:1.8.0131]atsun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [na:1.8.0131]atjava.lang.reflect.Method.invoke(Method.java:498) [na:1.8.0131]attk.mybatis.spring.mapper.SpringBootBindUtilSpringBoot2Bind.bind(SpringBootBindUtil.java:127) ~[mapper-spring-boot-autoconfigure-1.2.3.jar:na]
    … 21 common frames omitted
    Caused by: java.util.NoSuchElementException: No value bound
    at org.springframework.boot.context.properties.bind.BindResult.get(BindResult.java:56) ~[spring-boot-2.1.14.RELEASE.jar:2.1.14.RELEASE]
    … 26 common frames omitted

    Disconnected from the target VM, address: ‘127.0.0.1:65366’, transport: ‘socket’

    Process finished with exit code 1

    解决:
    在application.properties添加

    mapper.identity=MYSQL
    
    

    在这里插入图片描述

    展开全文
  • IllegalArgumentException是设置错了,field.get()参数需要的是该类对象,而不是该类的class对象 //Student student = new Student(); Class<Student> cls = Student.class; Field hhh = cls.getField("hhh...
  • 我有一個使用spring驗證器的用戶驗證器的書面單元測試用例。下面是類。我在Spring驗證器的validate方法中面臨問題,調用...如何解決java.lang.AssertionError:期望的異常:Mockito中的java.lang.Exceptionpublic c...
  • import java.util.List; import java.util.Map; @Controller @RequestMapping("/user") public class UserController { @Autowired private JdbcTemplate jdbcTemplate; @RequestMapping("findAll") public String ...
  • 开发中经常会遇到java.lang.String cannot be cast to java.lang.Integer异常,记录下我怎么解决的。 这种异常就是经常会出现类型转换的地方,这里面有些小坑,必须要踩过,撸源码才知道问题原因,哈哈。 比如我在...
  • java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.classwork10b/com.example.classwork10b.Sea_del_Avtivity}: java.lang.IllegalAccessException: java.lang.Class<...
  • 2020-10-28 21:33:17 |DEBUG |main |DirectJDKLog.java:175 |org.apache.tomcat.util.compat.Jre9Compat |...java.lang.ClassNotFoundException: java.lang.reflect.InaccessibleObjectException 升级JDK版本 9及以上
  • } 用Postman调用API报错如下: java.lang.ClassCastException: class java.lang.Integer cannot be cast to class java.lang.Long (java.lang.Integer and java.lang.Long are in module java.base of loader '...
  • java.lang.ClassCastException: java.math.BigInteger cannot be cast to java.lang.Long问题描述:报错信息:Error querying database. Cause: java.sql.SQLException: java.lang.ClassCastException: java.math....
  • Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Character  at org.apache.ibatis.type.CharacterTypeHandler.setNonNullParameter(CharacterTypeHandler.java:26)  at ...
  • nested exception is java.lang.ClassCastException: java.lang String cannot be cast to java.util.Map 首先,这个错误很明显,类型转换异常,当时后端查找了下,没问题,打断点根本就没有进入到程序中,同
  • Cause: java.lang.IllegalArgumentException: invalid comparison: java.util.Date and java.lang.String 原因是mybatis 对于时间参数进行比较时的一个bug. 如果拿传入的时间类型参数与空字符串''进行对比判断则...
  • @[TOC](解决 java.lang.ClassCastException: class java.lang.String cannot be cast to class java.lang.Integer (java.lang.String and java.lang.Integer are in module java.base of loader ‘bootstrap’)) ...
  • java.lang.ExceptionInInitializerError at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl....
  • java.lang.Integer cannot be cast to java.lang.Long解决办法

    万次阅读 多人点赞 2020-06-15 11:51:19
    你好我是辰兮,本次是项目遇到的java.lang.Integer cannot be cast to java.lang.Long异常以及相对应的解决方案。 文章目录 一、实战问题 二、源码学习 一、实战问题 用postman测试数据报错,类型转换异常! 如何将...
  • java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String 问题背景 接口中参数为 Map<String,Object>取出某 KEY 值时,强制将其转为 String ,出现上述异常 问题分析 以 Map&...
  • Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int) throws java.lang.ClassFormatError accessible: module java.base does not “opens java
  • 用List<String> list 接收的list,获取list长度,循环得到 list.get(i),想得到集合中的...java.lang.ClassCastException: java.util.HashMap cannot be cast to java.lang.String at io.renren.modules.equip...
  • java.lang.ClassNotFoundException:如何解决

    万次阅读 2020-05-08 17:05:39
    本文适用于当前面临java.lang.ClassNotFoundException挑战的Java初学者。 它将为您提供此常见Java异常的概述,这是一个示例Java程序,可支持您的学习过程和解决策略。 如果您对与更高级的类加载器相关的问题感兴趣...
  • mybatis中Date参数传入报异常:java.lang.ClassCastException: java.util.Date cannot be cast to java.lang.String; 异常信息如下: org.mybatis.spring.MyBatisSystemException: nested exception is org....
  • java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Long  at com.facishare.appserver.test.MyTest.main(MyTest.java:878)  at sun.reflect.NativeMethodAccessorImpl.invoke0...
  • 就会报java.lang.String cannot be cast to java.lang.Integer 从文字而言可以看出是 String不能转换成Integer类型 那么就用valueof Object operType = param.get(SpeedMessageKey.OPERTYPE.getValue()); if( ...
  • 项目:网上商城练习 问题:使用postman测试接口报错:类型转换异常 上代码: @GetMapping(value = "/search/{page}/{size}" ) public Result<PageInfo> findPage(@PathVariable(value = "page") int page, @...
  • java.lang.UnsatisfiedLinkError: no opencv_java430 in java.library.path 看起来像opencv的包没导入进来,后来的解决方法是在本地(windows系统)的jdk的bin中加一个opencv_java430.dll这个包,比如我加入后的...
  • springBoot 2.0 添加 日志级别,启动报错: org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'logging.level' to ...java.lang.String, java.lang.String&...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 1,272,459
精华内容 508,983
关键字:

java.lang

java 订阅
友情链接: 电影推荐算法.zip