如何在您的库中使用Spring-Data以及如何在您的项目中使用此库?

时间:2022-09-11 16:26:43

As you may or may not already see in the title, I try to figure out how to use spring data in my library and how to use this library in my other projects. (all not web-based applications just to clarify)

正如您可能已经或可能未在标题中看到的那样,我试图弄清楚如何在我的库中使用spring数据以及如何在我的其他项目中使用此库。 (所有不是基于网络的应用程序只是为了澄清)

I am trying to answer for several days for this problem, maybe I am just looking wrong, I am a total beginner as far as spring is concerned.

我试图回答这个问题几天,也许我只是看错了,就春天而言,我是一个初学者。

It only shows errors on startup.

它仅在启动时显示错误。

Find the project here https://gitlab.com/roboflax/Spring-Data-In-Library

在这里找到项目https://gitlab.com/roboflax/Spring-Data-In-Library

Error/s

Exception in thread "main" java.lang.IllegalArgumentException: Cannot instantiate interface org.springframework.boot.SpringApplicationRunListener : org.springframework.boot.context.event.EventPublishingRunListener at org.springframework.boot.SpringApplication.createSpringFactoriesInstances(SpringApplication.java:413) at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:392) at org.springframework.boot.SpringApplication.getRunListeners(SpringApplication.java:378) at org.springframework.boot.SpringApplication.run(SpringApplication.java:291) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) at ThePluginUsingTheLibrary.main(ThePluginUsingTheLibrary.java:24) Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.context.event.EventPublishingRunListener]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: org.springframework.aop.framework.AopProxyUtils.getSingletonTarget(Ljava/lang/Object;)Ljava/lang/Object; at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:163) at org.springframework.boot.SpringApplication.createSpringFactoriesInstances(SpringApplication.java:409) ... 6 more Caused by: java.lang.NoSuchMethodError: org.springframework.aop.framework.AopProxyUtils.getSingletonTarget(Ljava/lang/Object;)Ljava/lang/Object; at org.springframework.context.event.AbstractApplicationEventMulticaster.addApplicationListener(AbstractApplicationEventMulticaster.java:108) at org.springframework.boot.context.event.EventPublishingRunListener.(EventPublishingRunListener.java:56) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:147) ... 7 more

线程“main”中的异常java.lang.IllegalArgumentException:无法在org.springframework.boot.SpringApplication.createSpringFactoriesInstances(SpringApplication.java:413)中实例化接口org.springframework.boot.SpringApplicationRunListener:org.springframework.boot.context.event.EventPublishingRunListener )org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:392)org.springframework.boot.SpringApplication.getRunListeners(SpringApplication.java:378)org.springframework.boot.SpringApplication.run(SpringApplication.java: 291)org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)atg.springframework.boot.SpringApplication.run(SpringApplication.java:1107)atPluginUsingTheLibrary.main(ThePluginUsingTheLibrary.java:24)引起: org.springframework.beans.BeanInstantiationException:无法实例化[org.springframework.boot.context.event.EventPublishingRunListener]:构造函数抛出异常;嵌套异常是java.lang.NoSuchMethodError:org.springframework.aop.framework.AopProxyUtils.getSingletonTarget(Ljava / lang / Object;)Ljava / lang / Object; org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:163)org.springframework.boot.SpringApplication.createSpringFactoriesInstances(SpringApplication.java:409)... 6 more引起:java.lang.NoSuchMethodError:org。 springframework.aop.framework.AopProxyUtils.getSingletonTarget(Ljava /郎/对象;)Ljava /郎/对象; at org.springframework.context.event.AbstractApplicationEventMulticaster.addApplicationListener(AbstractApplicationEventMulticaster.java:108)atg.springframework.boot.context.event.EventPublishingRunListener。(EventPublishingRunListener.java:56)at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) )在sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)的sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)atg的java.lang.reflect.Constructor.newInstance(Constructor.java:423) .springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:147)... 7更多

(This could be an approach for an entry point to library but I think there is so mutch more wrong :/ https://*.com/a/35790770/9080835)

(这可能是一个入库点的方法,但我认为有更多错误:/ https://*.com/a/35790770/9080835)

Please ask if I left more information open and thanks for trying to help me!

请问我是否打开了更多信息并感谢您试图帮助我!

SOLVED I'm now just using the spring io platform for auto devendency management. Little tutorial for that: How to use Spring IO Platform and Spring Boot together and Spring Data JPA Tutorial: Getting the Required Dependencies

解决方案我现在只是使用spring io平台进行自动应急管理。小教程:如何一起使用Spring IO Platform和Spring Boot以及Spring Data JPA教程:获取所需的依赖项

1 个解决方案

#1


2  

This kind of exception is a sure sign that you have incompatible versions of you dependencies:

这种异常肯定表明您具有不兼容的依赖项版本:

Caused by: java.lang.NoSuchMethodError: org.springframework.aop.framework.AopProxyUtils.getSingletonTarget(Ljava/lang/Object;)Ljava/lang/Object; at 

Use mvn dependency:tree -Dverbose to see the versions of dependencies of your projects. Including conflicts (see https://maven.apache.org/plugins/maven-dependency-plugin/examples/resolving-conflicts-using-the-dependency-tree.html for an example).

使用mvn dependency:tree -Dverbose查看项目依赖项的版本。包括冲突(有关示例,请参阅https://maven.apache.org/plugins/maven-dependency-plugin/examples/resolving-conflicts-using-the-dependency-tree.html)。

Only use non-conflicting versions.

仅使用非冲突版本。

#1


2  

This kind of exception is a sure sign that you have incompatible versions of you dependencies:

这种异常肯定表明您具有不兼容的依赖项版本:

Caused by: java.lang.NoSuchMethodError: org.springframework.aop.framework.AopProxyUtils.getSingletonTarget(Ljava/lang/Object;)Ljava/lang/Object; at 

Use mvn dependency:tree -Dverbose to see the versions of dependencies of your projects. Including conflicts (see https://maven.apache.org/plugins/maven-dependency-plugin/examples/resolving-conflicts-using-the-dependency-tree.html for an example).

使用mvn dependency:tree -Dverbose查看项目依赖项的版本。包括冲突(有关示例,请参阅https://maven.apache.org/plugins/maven-dependency-plugin/examples/resolving-conflicts-using-the-dependency-tree.html)。

Only use non-conflicting versions.

仅使用非冲突版本。