swagger 更正应用程序的类路径,使其包含一个兼容的org.springframework.plugin.core.PluginRegistry版本

yqhsw0fo  于 2024-01-08  发布在  Spring
关注(0)|答案(7)|浏览(305)

我正在使用Spring Cloud将一个模块化应用程序迁移到一个微服务应用程序中,当我完成将一个模块迁移到微服务并运行它时,出现了一个问题:

更正应用程序的类路径,使其包含单一兼容版本的org.springframework.plugin.core.PluginRegistry
这是错误:

  1. An attempt was made to call a method that does not exist. The attempt was made from the following location:
  2. org.springframework.data.rest.core.support.UnwrappingRepositoryInvokerFactory.<init>(UnwrappingRepositoryInvokerFactory.java:57)
  3. The following method did not exist:
  4. org.springframework.plugin.core.PluginRegistry.of(Ljava/util/List;)Lorg/springframework/plugin/core/PluginRegistry;
  5. The method's class, org.springframework.plugin.core.PluginRegistry, is available from the following locations:
  6. jar:file:/~/.m2/repository/org/springframework/plugin/spring-plugin-core/1.2.0.RELEASE/spring-plugin-core-1.2.0.RELEASE.jar!/org/springframework/plugin/core/PluginRegistry.class
  7. It was loaded from the following location:
  8. file:/~/.m2/repository/org/springframework/plugin/spring-plugin-core/1.2.0.RELEASE/spring-plugin-core-1.2.0.RELEASE.jar
  9. Action:
  10. Correct the classpath of your application so that it contains a single, compatible version of org.springframework.plugin.core.PluginRegistry

字符串

This is my pom.xml:

  1. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  2. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  3. <modelVersion>4.0.0</modelVersion>
  4. <parent>
  5. <groupId>org.springframework.boot</groupId>
  6. <artifactId>spring-boot-starter-parent</artifactId>
  7. <version>2.3.0.RELEASE</version>
  8. <relativePath/> <!-- lookup parent from repository -->
  9. </parent>
  10. <groupId>org.sid</groupId>
  11. <artifactId>SF-postpros</artifactId>
  12. <version>0.0.1-SNAPSHOT</version>
  13. <name>SF-postpros</name>
  14. <description>Demo project for Spring Boot</description>
  15. <properties>
  16. <java.version>1.8</java.version>
  17. <spring-cloud.version>Hoxton.SR4</spring-cloud.version>
  18. </properties>
  19. <dependencies>
  20. <dependency>
  21. <groupId>org.springframework.boot</groupId>
  22. <artifactId>spring-boot-starter-actuator</artifactId>
  23. <exclusions>
  24. <exclusion>
  25. <groupId>org.springframework.boot</groupId>
  26. <artifactId>spring-boot-starter-logging</artifactId>
  27. </exclusion>
  28. </exclusions>
  29. </dependency>
  30. <dependency>
  31. <groupId>com.h2database</groupId>
  32. <artifactId>h2</artifactId>
  33. <scope>runtime</scope>
  34. </dependency>
  35. <dependency>
  36. <groupId>org.springframework.boot</groupId>
  37. <artifactId>spring-boot-starter-data-jpa</artifactId>
  38. </dependency>
  39. <dependency>
  40. <groupId>javax.validation</groupId>
  41. <artifactId>validation-api</artifactId>
  42. <version>2.0.1.Final</version>
  43. </dependency>
  44. <dependency>
  45. <groupId>com.querydsl</groupId>
  46. <artifactId>querydsl-apt</artifactId>
  47. </dependency>
  48. <dependency>
  49. <groupId>com.querydsl</groupId>
  50. <artifactId>querydsl-jpa</artifactId>
  51. </dependency>
  52. <dependency>
  53. <groupId>com.querydsl</groupId>
  54. <artifactId>querydsl-core</artifactId>
  55. </dependency>
  56. <dependency>
  57. <groupId>org.springframework.plugin</groupId>
  58. <artifactId>spring-plugin-core</artifactId>
  59. <version>1.2.0.RELEASE</version>
  60. </dependency>
  61. <dependency>
  62. <groupId>org.springframework.boot</groupId>
  63. <artifactId>spring-boot-starter-security</artifactId>
  64. </dependency>
  65. <dependency>
  66. <groupId>org.springframework.cloud</groupId>
  67. <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
  68. </dependency>
  69. <dependency>
  70. <groupId>org.springframework.cloud</groupId>
  71. <artifactId>spring-cloud-starter-netflix-zuul</artifactId>
  72. </dependency>
  73. <dependency>
  74. <groupId>org.springframework.boot</groupId>
  75. <artifactId>spring-boot-starter-test</artifactId>
  76. <scope>test</scope>
  77. <exclusions>
  78. <exclusion>
  79. <groupId>org.junit.vintage</groupId>
  80. <artifactId>junit-vintage-engine</artifactId>
  81. </exclusion>
  82. </exclusions>
  83. </dependency>
  84. <dependency>
  85. <groupId>org.springframework.security</groupId>
  86. <artifactId>spring-security-test</artifactId>
  87. <scope>test</scope>
  88. </dependency>
  89. <dependency>
  90. <groupId>org.junit.jupiter</groupId>
  91. <artifactId>junit-jupiter-engine</artifactId>
  92. <scope>test</scope>
  93. </dependency>
  94. <dependency>
  95. <groupId>org.junit.platform</groupId>
  96. <artifactId>junit-platform-launcher</artifactId>
  97. <scope>test</scope>
  98. </dependency>
  99. <dependency>
  100. <groupId>com.google.code.gson</groupId>
  101. <artifactId>gson</artifactId>
  102. </dependency>
  103. <dependency>
  104. <groupId>com.fasterxml.jackson.datatype</groupId>
  105. <artifactId>jackson-datatype-jsr310</artifactId>
  106. </dependency>
  107. <dependency>
  108. <groupId>com.fasterxml.jackson.core</groupId>
  109. <artifactId>jackson-databind</artifactId>
  110. </dependency>
  111. <dependency>
  112. <groupId>com.fasterxml.jackson.core</groupId>
  113. <artifactId>jackson-core</artifactId>
  114. </dependency>
  115. <dependency>
  116. <groupId>com.fasterxml.jackson.core</groupId>
  117. <artifactId>jackson-annotations</artifactId>
  118. </dependency>
  119. <dependency>
  120. <groupId>io.springfox</groupId>
  121. <artifactId>springfox-swagger-ui</artifactId>
  122. <version>2.9.2</version>
  123. </dependency>
  124. <dependency>
  125. <groupId>io.springfox</groupId>
  126. <artifactId>springfox-swagger2</artifactId>
  127. <version>2.9.2</version>
  128. </dependency>
  129. <dependency>
  130. <groupId>org.apache.commons</groupId>
  131. <artifactId>commons-lang3</artifactId>
  132. </dependency>
  133. <dependency>
  134. <groupId>org.springframework.boot</groupId>
  135. <artifactId>spring-boot-starter-log4j2</artifactId>
  136. </dependency>
  137. <dependency>
  138. <groupId>org.springframework.boot</groupId>
  139. <artifactId>spring-boot-starter-aop</artifactId>
  140. <exclusions>
  141. <exclusion>
  142. <groupId>org.springframework.boot</groupId>
  143. <artifactId>spring-boot-starter-logging</artifactId>
  144. </exclusion>
  145. </exclusions>
  146. </dependency>
  147. <dependency>
  148. <groupId>org.springframework.boot</groupId>
  149. <artifactId>spring-boot-starter-data-rest</artifactId>
  150. </dependency>
  151. <dependency>
  152. <groupId>mysql</groupId>
  153. <artifactId>mysql-connector-java</artifactId>
  154. </dependency>
  155. <dependency>
  156. <groupId>org.springframework.boot</groupId>
  157. <artifactId>spring-boot-starter-data-redis</artifactId>
  158. <exclusions>
  159. <exclusion>
  160. <groupId>org.springframework.boot</groupId>
  161. <artifactId>spring-boot-starter-logging</artifactId>
  162. </exclusion>
  163. </exclusions>
  164. </dependency>
  165. <dependency>
  166. <groupId>org.springframework.boot</groupId>
  167. <artifactId>spring-boot-starter-thymeleaf</artifactId>
  168. </dependency>
  169. <dependency>
  170. <groupId>org.springframework.boot</groupId>
  171. <artifactId>spring-boot-starter-batch</artifactId>
  172. </dependency>
  173. <dependency>
  174. <groupId>commons-io</groupId>
  175. <artifactId>commons-io</artifactId>
  176. <version>2.6</version>
  177. </dependency>
  178. <dependency>
  179. <groupId>org.springframework.boot</groupId>
  180. <artifactId>spring-boot-starter-websocket</artifactId>
  181. </dependency>
  182. <dependency>
  183. <groupId>org.webjars</groupId>
  184. <artifactId>sockjs-client</artifactId>
  185. <version>1.0.2</version>
  186. </dependency>
  187. <dependency>
  188. <groupId>org.webjars</groupId>
  189. <artifactId>stomp-websocket</artifactId>
  190. <version>2.3.3</version>
  191. </dependency>
  192. <dependency>
  193. <groupId>org.webjars</groupId>
  194. <artifactId>bootstrap</artifactId>
  195. <version>4.1.3</version>
  196. </dependency>
  197. <dependency>
  198. <groupId>org.webjars</groupId>
  199. <artifactId>jquery</artifactId>
  200. <version>3.3.1-1</version>
  201. </dependency>
  202. <dependency>
  203. <groupId>redis.clients</groupId>
  204. <artifactId>jedis</artifactId>
  205. <type>jar</type>
  206. </dependency>
  207. <dependency>
  208. <groupId>org.springframework.boot</groupId>
  209. <artifactId>spring-boot-starter-web</artifactId>
  210. <exclusions>
  211. <exclusion>
  212. <groupId>org.springframework.boot</groupId>
  213. <artifactId>spring-boot-starter-logging</artifactId>
  214. </exclusion>
  215. </exclusions>
  216. </dependency>
  217. <dependency>
  218. <groupId>org.springframework.boot</groupId>
  219. <artifactId>spring-boot-starter-mail</artifactId>
  220. </dependency>
  221. <dependency>
  222. <groupId>nz.net.ultraq.thymeleaf</groupId>
  223. <artifactId>thymeleaf-layout-dialect</artifactId>
  224. </dependency>
  225. <dependency>
  226. <groupId>org.projectlombok</groupId>
  227. <artifactId>lombok</artifactId>
  228. <version>1.18.4</version>
  229. <scope>provided</scope>
  230. </dependency>
  231. <dependency>
  232. <groupId>org.xhtmlrenderer</groupId>
  233. <artifactId>flying-saucer-pdf</artifactId>
  234. <version>9.1.4</version>
  235. </dependency>
  236. <dependency>
  237. <groupId>org.apache.pdfbox</groupId>
  238. <artifactId>pdfbox</artifactId>
  239. <version>2.0.11</version>
  240. </dependency>
  241. <dependency>
  242. <groupId>org.apache.pdfbox</groupId>
  243. <artifactId>pdfbox-tools</artifactId>
  244. <version>2.0.11</version>
  245. </dependency>
  246. <dependency>
  247. <groupId>com.github.jai-imageio</groupId>
  248. <artifactId>jai-imageio-jpeg2000</artifactId>
  249. <version>1.3.0</version>
  250. </dependency>
  251. <dependency>
  252. <groupId>net.sf.dozer</groupId>
  253. <artifactId>dozer</artifactId>
  254. <version>5.5.1</version>
  255. </dependency>
  256. <dependency>
  257. <groupId>com.google.guava</groupId>
  258. <artifactId>guava</artifactId>
  259. <version>25.1-jre</version>
  260. </dependency>
  261. <dependency>
  262. <groupId>org.springframework.cloud</groupId>
  263. <artifactId>spring-cloud-starter-openfeign</artifactId>
  264. <exclusions>
  265. <exclusion>
  266. <groupId>org.springframework.boot</groupId>
  267. <artifactId>spring-boot-starter-logging</artifactId>
  268. </exclusion>
  269. </exclusions>
  270. </dependency>
  271. </dependencies>
  272. <dependencyManagement>
  273. <dependencies>
  274. <dependency>
  275. <groupId>org.springframework.cloud</groupId>
  276. <artifactId>spring-cloud-dependencies</artifactId>
  277. <version>${spring-cloud.version}</version>
  278. <type>pom</type>
  279. <scope>import</scope>
  280. </dependency>
  281. </dependencies>
  282. </dependencyManagement>
  283. <build>
  284. <plugins>
  285. <plugin>
  286. <groupId>org.springframework.boot</groupId>
  287. <artifactId>spring-boot-maven-plugin</artifactId>
  288. </plugin>
  289. <plugin>
  290. <groupId>com.mysema.maven</groupId>
  291. <artifactId>apt-maven-plugin</artifactId>
  292. <version>1.1.3</version>
  293. <executions>
  294. <execution>
  295. <goals>
  296. <goal>process</goal>
  297. </goals>
  298. <configuration>
  299. <outputDirectory>target/generated-sources</outputDirectory>
  300. <processor>com.querydsl.apt.jpa.JPAAnnotationProcessor</processor>
  301. </configuration>
  302. </execution>
  303. </executions>
  304. </plugin>
  305. <plugin>
  306. <groupId>org.apache.maven.plugins</groupId>
  307. <version>2.19.1</version><!--$NO-MVN-MAN-VER$ -->
  308. <artifactId>maven-surefire-plugin</artifactId>
  309. <configuration>
  310. <includes>
  311. <include>**/*.class</include>
  312. </includes>
  313. </configuration>
  314. <dependencies>
  315. <dependency>
  316. <groupId>org.junit.platform</groupId>
  317. <artifactId>junit-platform-surefire-provider</artifactId>
  318. <version>1.0.2</version>
  319. </dependency>
  320. </dependencies>
  321. </plugin>
  322. </plugins>
  323. </build>
  324. </project>

这是我的SwaggerConfig.java:

  1. package org.sid.SFpostpros.config;
  2. import org.springframework.context.annotation.Bean;
  3. import org.springframework.context.annotation.Configuration;
  4. import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
  5. import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
  6. import springfox.documentation.builders.PathSelectors;
  7. import springfox.documentation.builders.RequestHandlerSelectors;
  8. import springfox.documentation.service.ApiInfo;
  9. import springfox.documentation.service.Contact;
  10. import springfox.documentation.spi.DocumentationType;
  11. import springfox.documentation.spring.web.plugins.Docket;
  12. import springfox.documentation.swagger2.annotations.EnableSwagger2;
  13. import java.util.Collections;
  14. // TODO: Auto-generated Javadoc
  15. /**
  16. * The Class SwaggerConf.
  17. */
  18. @Configuration
  19. @EnableSwagger2
  20. public class SwaggerConf implements WebMvcConfigurer {
  21. /**
  22. * Api.
  23. *
  24. * @return the docket
  25. */
  26. @Bean
  27. public Docket api() {
  28. return new Docket(DocumentationType.SWAGGER_2).select().apis(RequestHandlerSelectors.any())
  29. .paths(PathSelectors.any()).build().apiInfo(this.custInfo());
  30. }
  31. /**
  32. * Cust info.
  33. *
  34. * @return the api info
  35. */
  36. public ApiInfo custInfo() {
  37. return new ApiInfo("Test", // Title
  38. "Spring Boot Services", // Description
  39. "1.0", // Version
  40. "TOS", // Terms of Service
  41. new Contact("Test", "Test.com", "[email protected]"), // Contact
  42. "Test license", // License
  43. "License", Collections.emptyList());
  44. }
  45. /**
  46. * Adds the resource handlers.
  47. *
  48. * @param registry the registry
  49. */
  50. @Override
  51. public void addResourceHandlers(final ResourceHandlerRegistry registry) {
  52. registry.addResourceHandler("swagger-ui.html")
  53. .addResourceLocations("classpath:/META-INF/resources/");
  54. registry.addResourceHandler("/webjars/**")
  55. .addResourceLocations("classpath:/META-INF/resources/webjars/");
  56. }
  57. }


有人可以帮助我,因为我尝试了这么多的东西,没有工作。

drkbr07n

drkbr07n1#

将此依赖项添加到您的依赖项部分解决了问题:

  1. <dependency>
  2. <groupId>org.springframework.plugin</groupId>
  3. <artifactId>spring-plugin-core</artifactId>
  4. <version>2.0.0.RELEASE</version>
  5. </dependency>

字符串
来源:https://github.com/springfox/springfox/issues/2932

2jcobegt

2jcobegt2#

对我来说,我使用的是spring fox版本2.9.2,在springFox版本做了一些更改后,我发现解决这个问题的最佳方法是使用 springfox-starter 版本,它为你做了所有的事情。

  1. <dependency>
  2. <groupId>io.springfox</groupId>
  3. <artifactId>springfox-boot-starter</artifactId>
  4. </dependency>

字符串

shyt4zoc

shyt4zoc3#

为什么你缺少Sping Boot starter插件。它负责所有匹配的依赖版本。如果它由Spring管理,请不要显式指定任何jar版本。有一个Spring- Boot -dependency jar浏览它以查找Spring管理的版本。您也可以参考Spring文档页面https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#dependency-versions-coordinates。

nqwrtyyt

nqwrtyyt4#

与SprintBoot 2.3.3.只有这解决了我:

  1. <dependency>
  2. <groupId>org.springframework.boot</groupId>
  3. <artifactId>spring-boot-starter-actuator</artifactId>
  4. </dependency>

字符串

xytpbqjk

xytpbqjk5#

  1. <dependency>
  2. <groupId>org.springframework.data</groupId>
  3. <artifactId>spring-data-releasetrain</artifactId>
  4. <version>Neumann-SR4</version>
  5. <scope>import</scope>
  6. <type>pom</type>
  7. </dependency>

字符串
目标Spring文档链接

hfyxw5xn

hfyxw5xn6#

这是我在使用Spring-boot 2.3.4-RELEASE版本配置SWAGGER 2.9.2时遇到的相同问题。如果我将SWAGGER版本指向3.0.0,我会遇到白色标签错误的问题。最后,我修复了这个问题并记录了配置SWAGGER 3.0.0的步骤
当多个版本的SPRING-CORE-PLUGIN作为依赖项下载的一部分被下载时,将发生此问题。

dkqlctbz

dkqlctbz7#

以前我的pom.xml文件父是

  1. <parent>
  2. <groupId>org.springframework.boot</groupId>
  3. <artifactId>spring-boot-starter-parent</artifactId>
  4. <version>3.2.0</version>
  5. <relativePath/> <!-- lookup parent from repository -->
  6. </parent>

字符串
当我改变我的pom.xml文件父版本3.2.0降级到2.7.17。然后应用程序的工作。

  1. <parent>
  2. <groupId>org.springframework.boot</groupId>
  3. <artifactId>spring-boot-starter-parent</artifactId>
  4. <version>2.7.17</version>
  5. <relativePath/> <!-- lookup parent from repository -->
  6. </parent>


当降级时,我们需要更换这些包

  1. import jakarta.persistence.Entity;
  2. import jakarta.persistence.Id;
  3. import jakarta.persistence.Table;


  1. import javax.persistence.*;


在完成这些事情后,我的应用程序开始正常工作

展开查看全部

相关问题