wh1t3p1g / tabby

A CAT called tabby ( Code Analysis Tool )
https://www.yuque.com/wh1t3p1g/tp0c1t/lf12lg69ngh47akx
Apache License 2.0
1.3k stars 153 forks source link

tabby 在命令行运行正确,但在IDEA运行报错 #37

Closed FizzFish closed 2 years ago

FizzFish commented 2 years ago

在命令行下,java -Xmx6g -jar ./build/libs/tabby-1.1.1.RELEASE.jar没问题。 但在IDEA开发环境下,运行APP或Test都会报一个SpringBoot的错误,报错信息提示在下面函数增加@param选项,但还是没法解决。 java.lang.IllegalStateException: Failed to execute CommandLineRunner For queries with named parameters you need to use provide names for method parameters. Use @Param for query method parameters, or when on Java 8+ use the javac flag -parameters.

public MethodReference getMethodRefBySignature(String signature){
    return methodRepository.findMethodReferenceBySignature(signature);
}

报错信息如下,更换过java版本(jdk1.8.0_342/1.8.0_341/1.8.0_352),都是一样的情况; 更换OS(win10/ubuntu22)也是同样的情况。

java.lang.IllegalStateException: Failed to execute CommandLineRunner
    at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:822) [spring-boot-2.4.5.jar:2.4.5]
    at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:803) [spring-boot-2.4.5.jar:2.4.5]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:346) [spring-boot-2.4.5.jar:2.4.5]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1340) [spring-boot-2.4.5.jar:2.4.5]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1329) [spring-boot-2.4.5.jar:2.4.5]
    at tabby.App.main(App.java:36) [classes/:na]
Caused by: org.springframework.dao.InvalidDataAccessApiUsageException: **For queries with named parameters you need to use provide names for method parameters. Use @Param for query method parameters, or when on Java 8+ use the javac flag -parameters.;** nested exception is java.lang.IllegalStateException: For queries with named parameters you need to use provide names for method parameters. Use @Param for query method parameters, or when on Java 8+ use the javac flag -parameters.
    at org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(EntityManagerFactoryUtils.java:371) ~[spring-orm-5.3.6.jar:5.3.6]
    at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:235) ~[spring-orm-5.3.6.jar:5.3.6]
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:551) ~[spring-orm-5.3.6.jar:5.3.6]
    at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:61) ~[spring-tx-5.3.6.jar:5.3.6]
    at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:242) ~[spring-tx-5.3.6.jar:5.3.6]
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:152) ~[spring-tx-5.3.6.jar:5.3.6]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.6.jar:5.3.6]
    at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:145) ~[spring-data-jpa-2.4.8.jar:2.4.8]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.6.jar:5.3.6]
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97) ~[spring-aop-5.3.6.jar:5.3.6]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.6.jar:5.3.6]
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:215) ~[spring-aop-5.3.6.jar:5.3.6]
    at com.sun.proxy.$Proxy90.findMethodReferenceBySignature(Unknown Source) ~[na:na]
    at tabby.dal.caching.service.MethodRefService.getMethodRefBySignature(MethodRefService.java:24) ~[classes/:na]
    at tabby.core.container.DataContainer.getMethodRefBySubSignature(DataContainer.java:172) ~[classes/:na]
    at tabby.core.container.DataContainer.getAliasMethodRefs(DataContainer.java:335) ~[classes/:na]
    at tabby.core.scanner.ClassInfoScanner.makeAliasRelation(ClassInfoScanner.java:203) ~[classes/:na]
    at tabby.core.scanner.ClassInfoScanner.makeAliasRelations(ClassInfoScanner.java:183) ~[classes/:na]
    at tabby.core.scanner.ClassInfoScanner.extractRelationships(ClassInfoScanner.java:137) ~[classes/:na]
    at tabby.core.scanner.ClassInfoScanner.buildClassEdges(ClassInfoScanner.java:102) ~[classes/:na]
    at tabby.core.scanner.ClassInfoScanner.run(ClassInfoScanner.java:44) ~[classes/:na]
    at tabby.core.Analyser.runSootAnalysis(Analyser.java:107) ~[classes/:na]
    at tabby.core.Analyser.run(Analyser.java:81) ~[classes/:na]
    at tabby.App.lambda$run$0(App.java:89) [classes/:na]
FizzFish commented 2 years ago

我发现用默认的gradle没问题,但是用Intelij IDEA作为gradle就会出上面的错误。 不知道为什么会这样,因为一般认为Idea的gradle速度会快一点。 gradle

wh1t3p1g commented 2 years ago

可以尝试加 @Param, 我一般用的不是idea的

FizzFish commented 2 years ago

感谢!