spring—找不到soap web服务的jaxb api实现

4uqofj5v  于 2021-07-23  发布在  Java
关注(0)|答案(0)|浏览(273)

我正在尝试使用spring启动项目连接到soapweb服务。我可以从wsdl生成类,并且可以确认生成的类最终位于目标文件夹中。但是,我不能运行这个项目。
我错过了什么?我想是依赖吧?我已经把我能想到的都包括进去了。
另外,如果有其他方法可以完全避免这种依赖性混乱,那么我们也会非常感激
这就是我尝试运行项目时发生的情况。

  1. java -version
  2. openjdk version "15.0.2" 2021-01-19
  3. OpenJDK Runtime Environment AdoptOpenJDK (build 15.0.2+7)
  4. ./mvnw clean && ./mvnw jaxb2:generate
  5. BUILD SUCCESS
  6. ./mvnw spring-boot:run
  7. Application run failed
  8. Implementation of JAXB-API has not been found on module path or classpath.
  9. java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory

这是我的pom文件。

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  4. <modelVersion>4.0.0</modelVersion>
  5. <parent>
  6. <groupId>org.springframework.boot</groupId>
  7. <artifactId>spring-boot-starter-parent</artifactId>
  8. <version>2.4.2</version>
  9. <relativePath/> <!-- lookup parent from repository -->
  10. </parent>
  11. <groupId>com.test</groupId>
  12. <artifactId>test</artifactId>
  13. <version>0.0.1-SNAPSHOT</version>
  14. <name>api</name>
  15. <properties>
  16. <java.version>15</java.version>
  17. <kotlin.version>1.4.21</kotlin.version>
  18. <maven.compiler.target>15</maven.compiler.target>
  19. <maven.compiler.source>15</maven.compiler.source>
  20. </properties>
  21. <dependencies>
  22. <dependency>
  23. <groupId>org.springframework.boot</groupId>
  24. <artifactId>spring-boot-starter-data-jdbc</artifactId>
  25. </dependency>
  26. <dependency>
  27. <groupId>org.springframework.boot</groupId>
  28. <artifactId>spring-boot-starter-web</artifactId>
  29. </dependency>
  30. <dependency>
  31. <groupId>org.springframework.boot</groupId>
  32. <artifactId>spring-boot-starter-security</artifactId>
  33. </dependency>
  34. <dependency>
  35. <groupId>org.springframework.boot</groupId>
  36. <artifactId>spring-boot-starter-oauth2-resource-server</artifactId>
  37. </dependency>
  38. <dependency>
  39. <groupId>org.springframework.boot</groupId>
  40. <artifactId>spring-boot-configuration-processor</artifactId>
  41. <optional>true</optional>
  42. </dependency>
  43. <dependency>
  44. <groupId>org.postgresql</groupId>
  45. <artifactId>postgresql</artifactId>
  46. <scope>runtime</scope>
  47. </dependency>
  48. <dependency>
  49. <groupId>com.sendgrid</groupId>
  50. <artifactId>sendgrid-java</artifactId>
  51. <version>4.7.1</version>
  52. </dependency>
  53. <dependency>
  54. <groupId>com.stripe</groupId>
  55. <artifactId>stripe-java</artifactId>
  56. <version>20.36.0</version>
  57. </dependency>
  58. <dependency>
  59. <groupId>org.jetbrains.kotlin</groupId>
  60. <artifactId>kotlin-reflect</artifactId>
  61. </dependency>
  62. <dependency>
  63. <groupId>org.jetbrains.kotlin</groupId>
  64. <artifactId>kotlin-stdlib-jdk8</artifactId>
  65. </dependency>
  66. <dependency>
  67. <groupId>org.springframework.boot</groupId>
  68. <artifactId>spring-boot-starter-test</artifactId>
  69. <scope>test</scope>
  70. </dependency>
  71. <!-- I included everything I could think of here... -->
  72. <dependency>
  73. <groupId>org.springframework.boot</groupId>
  74. <artifactId>spring-boot-starter-web-services</artifactId>
  75. <exclusions>
  76. <exclusion>
  77. <groupId>org.springframework.boot</groupId>
  78. <artifactId>spring-boot-starter-tomcat</artifactId>
  79. </exclusion>
  80. </exclusions>
  81. </dependency>
  82. <dependency>
  83. <groupId>javax.xml.bind</groupId>
  84. <artifactId>jaxb-api</artifactId>
  85. <version>2.3.1</version>
  86. </dependency>
  87. <dependency>
  88. <groupId>javax.activation</groupId>
  89. <artifactId>activation</artifactId>
  90. <version>1.1.1</version>
  91. </dependency>
  92. <dependency>
  93. <groupId>org.glassfish.jaxb</groupId>
  94. <artifactId>jaxb-runtime</artifactId>
  95. <version>3.0.0</version>
  96. </dependency>
  97. <dependency>
  98. <groupId>com.sun.xml.bind</groupId>
  99. <artifactId>jaxb-impl</artifactId>
  100. <version>3.0.0</version>
  101. </dependency>
  102. <dependency>
  103. <groupId>com.sun.xml.bind</groupId>
  104. <artifactId>jaxb-core</artifactId>
  105. <version>3.0.0</version>
  106. </dependency>
  107. <dependency>
  108. <groupId>com.fasterxml.jackson.module</groupId>
  109. <artifactId>jackson-module-kotlin</artifactId>
  110. </dependency>
  111. </dependencies>
  112. <build>
  113. <sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
  114. <testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
  115. <plugins>
  116. <plugin>
  117. <groupId>org.springframework.boot</groupId>
  118. <artifactId>spring-boot-maven-plugin</artifactId>
  119. </plugin>
  120. <plugin>
  121. <groupId>org.jetbrains.kotlin</groupId>
  122. <artifactId>kotlin-maven-plugin</artifactId>
  123. <configuration>
  124. <args>
  125. <arg>-Xjsr305=strict</arg>
  126. </args>
  127. <compilerPlugins>
  128. <plugin>spring</plugin>
  129. </compilerPlugins>
  130. </configuration>
  131. <dependencies>
  132. <dependency>
  133. <groupId>org.jetbrains.kotlin</groupId>
  134. <artifactId>kotlin-maven-allopen</artifactId>
  135. <version>${kotlin.version}</version>
  136. </dependency>
  137. </dependencies>
  138. </plugin>
  139. <plugin>
  140. <groupId>org.jvnet.jaxb2.maven2</groupId>
  141. <artifactId>maven-jaxb2-plugin</artifactId>
  142. <version>0.14.0</version>
  143. <executions>
  144. <execution>
  145. <goals>
  146. <goal>generate</goal>
  147. </goals>
  148. </execution>
  149. </executions>
  150. <configuration>
  151. <schemaLanguage>WSDL</schemaLanguage>
  152. <generatePackage>PACKAGE</generatePackage>
  153. <schemas>
  154. <schema>
  155. <url>URL</url>
  156. </schema>
  157. </schemas>
  158. </configuration>
  159. </plugin>
  160. </plugins>
  161. </build>
  162. </project>

编辑:
删除所有与jax相关的依赖项,除了 spring-boot-starter-web-services 导致同样的错误。

  1. javax.xml.bind.JAXBException: Implementation of JAXB-API has not been found on module path or classpath.
  2. java.lang.ClassNotFoundException: com.sun.xml.bind.v2.ContextFactory

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题