eclipse 尝试从 WSDL 文件生成时出现 Maven 问题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28501463/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Maven trouble when trying to generate from WSDL file
提问by javawocky
Im trying to generate sources from a wsdl file, but I keep running into an error on my pom.xml that I believe might be my issue? Below is the error that I get from my pom, and my pom file. Also I cannot build the project with "mvn clean install". I just seem to get an error with no real cause.
我试图从 wsdl 文件生成源代码,但我一直在 pom.xml 上遇到错误,我认为这可能是我的问题?下面是我从我的 pom 和我的 pom 文件中得到的错误。我也无法使用“mvn clean install”构建项目。我似乎只是收到一个没有真正原因的错误。
The error at the generates tag:
生成标签处的错误:
Execution default of goal org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.12.3:generate failed: A required class was missing while executing org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.12.3:generate: com/sun/codemodel/CodeWriter
-----------------------------------------------------
realm = plugin>org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.12.3-715230752
strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
urls[0] = file:/C:/Users/Windows/.m2/repository/org/jvnet/jaxb2/maven2/maven-jaxb2-plugin/0.12.3/maven-jaxb2-plugin-0.12.3.jar
urls[1] = file:/C:/Users/Windows/.m2/repository/org/jvnet/jaxb2/maven2/maven-jaxb2-plugin-core/0.12.3/maven-jaxb2-plugin-core-0.12.3.jar
urls[2] = file:/C:/Users/Windows/.m2/repository/org/slf4j/slf4j-api/1.7.7/slf4j-api-1.7.7.jar
urls[3] = file:/C:/Users/Windows/.m2/repository/org/apache/commons/commons-lang3/3.2.1/commons-lang3-3.2.1.jar
urls[4] = file:/C:/Users/Windows/.m2/repository/com/sun/org/apache/xml/internal/resolver/20050927/resolver-20050927.jar
urls[5] = file:/C:/Users/Windows/.m2/repository/junit/junit/4.8.1/junit-4.8.1.jar
urls[6] = file:/C:/Users/Windows/.m2/repository/org/codehaus/plexus/plexus-utils/1.5.15/plexus-utils-1.5.15.jar
urls[7] = file:/C:/Users/Windows/.m2/repository/org/jvnet/jaxb2/maven2/maven-jaxb22-plugin/0.12.3/maven-jaxb22-plugin-0.12.3.jar
urls[8] = file:/C:/Users/Windows/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.2.11/jaxb-runtime-2.2.11.jar
urls[9] = file:/C:/Users/Windows/.m2/repository/org/glassfish/jaxb/jaxb-xjc/2.2.11/jaxb-xjc-2.2.11.jar
urls[10] = file:/C:/Users/Windows/.m2/repository/org/apache/maven/plugin-tools/maven-plugin-annotations/3.2/maven-plugin-annotations-3.2.jar
Number of foreign imports: 5
import: Entry[import org.sonatype.plexus.build.incremental from realm ClassRealm[plexus.core, parent: null]]
import: Entry[import org.codehaus.plexus.util.Scanner from realm ClassRealm[plexus.core, parent: null]]
import: Entry[import org.codehaus.plexus.util.DirectoryScanner from realm ClassRealm[plexus.core, parent: null]]
import: Entry[import org.codehaus.plexus.util.AbstractScanner from realm ClassRealm[plexus.core, parent: null]]
import: Entry[import from realm ClassRealm[maven.api, parent: null]]
-----------------------------------------------------
(org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.12.3:generate:default:generate-sources)
my pom.xml file :
我的 pom.xml 文件:
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-ws-core</artifactId>
</dependency>
<dependency>
<groupId>com.bigthunk</groupId>
<artifactId>BigThunkCore</artifactId>
<version>0.0.7-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.bigthunk</groupId>
<artifactId>BigThunkWeb</artifactId>
<version>0.0.4-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!-- tag::wsdl[] -->
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<schemaLanguage>WSDL</schemaLanguage>
<generatePackage>hello.wsdl</generatePackage>
<forceRegenerate>true</forceRegenerate>
<schemas>
<schema>
<url>http://172.19.137.21:8280/services/umarketsc?wsdl</url>
</schema>
</schemas>
</configuration>
</plugin>
<!-- end::wsdl[] -->
</plugins>
</build>
<repositories>
<repository>
<id>project.local</id>
<name>project</name>
<url>file:${project.basedir}/repo</url>
</repository>
<repository>
<id>spring-releases</id>
<name>Spring Releases</name>
<url>https://repo.spring.io/libs-release</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-releases</id>
<url>https://repo.spring.io/libs-release</url>
</pluginRepository>
</pluginRepositories>
回答by Simeon Leyzerzon
Enclosing the <plugins>
tag inside <pluginManagement>
tag (as detailed here: How to solve "Plugin execution not covered by lifecycle configuration" for Spring Data Maven Builds) fixed the issue for me.
将<plugins>
标签包含在标签内<pluginManagement>
(详见此处:如何解决 Spring Data Maven Builds 的“生命周期配置未涵盖的插件执行”)为我解决了这个问题。
回答by martin
Change your Java Path jre to your jdk path and it will be fine! In Eclipse you can also change your "Installed JRE" to your jdk.
把你的Java Path jre 改成你的jdk 路径就可以了!在 Eclipse 中,您还可以将“已安装的 JRE”更改为您的 jdk。
Hope it will work for you.
希望它对你有用。
回答by Alberto Velasco
In my case, I fixed it by changing the JAXB specification version as instructed in the plugin wiki:
就我而言,我按照插件 wiki 中的说明通过更改 JAXB 规范版本来修复它:
https://github.com/highsource/maven-jaxb2-plugin/wiki/Using-a-Specific-JAXB-Version
https://github.com/highsource/maven-jaxb2-plugin/wiki/Using-a-Specific-JAXB-Version
Either by using the config option specVersion=2.0or by using the version-specific plugin: maven-jaxb20-plugin
通过使用配置选项specVersion=2.0或使用特定于版本的插件:maven-jaxb20-plugin
回答by Ronan Fauglas
For me this is a environment (java runtime) problem. I could solve similar issue triggered by m2e in my context, by launching eclipse in Windows command prompt : eclipse.exe -vm "C:\Program Files\Java\jdk1.8.0_25\bin\javaw.exe" (ensure it comes before "-vmargs") Then i tried to clean up my eclipse.ini in the same way to launch eclipse from explorer, it does work. When I have look at the eclipse command in Javavisual VM I see through Jvisual vm that eclipse looks that way
对我来说,这是一个环境(java 运行时)问题。我可以通过在 Windows 命令提示符下启动 eclipse 来解决 m2e 在我的上下文中触发的类似问题:eclipse.exe -vm "C:\Program Files\Java\jdk1.8.0_25\bin\javaw.exe"(确保它出现在“-vmargs”)然后我尝试以与从资源管理器启动 eclipse 相同的方式清理我的 eclipse.ini,它确实有效。当我在 Javavisual VM 中查看 eclipse 命令时,我通过 Jvisual vm 看到 eclipse 看起来是这样的
eclipse.commands=-os
win32
...
-vm "C:\Program Files\Java\jdk1.8.0_25\bin\javaw.exe"
-vm C:\Program Files\Java\jre1.8.0_25\bin\server\jvm.dll
Last line does not come from my eclipse.ini, but was appended by Eclipse launcher.In the system prooperties: eclipse.vm=C:\Program Files\Java\jre1.8.0_25\bin\server\jvm.dll This looks like "when launched from explorer", Eclipse luna appends parameter from jre found on the PATH which overrides eclipse.ini... There must be some difference in the environment that can account for the different behaviour of the process.
最后一行不是来自我的 eclipse.ini,而是由 Eclipse 启动器附加的。在系统属性中: eclipse.vm=C:\Program Files\Java\jre1.8.0_25\bin\server\jvm.dll 这看起来像“当从资源管理器启动时”,Eclipse luna 附加来自 PATH 上找到的 jre 的参数,该参数覆盖了 eclipse.ini ......环境中必须存在一些差异,可以解释进程的不同行为。
回答by nEraquasAr
I had this problem, but I was able to solve it:
我遇到了这个问题,但我能够解决它:
- I deleted ALL single JRE file (previous and current versions)
- Added to "Path"
C:\Program Files\Java\jdk1.8.0_91\jre\bin
(I work on Win10) - Profit.
- 我删除了所有单个 JRE 文件(以前的和当前的版本)
- 添加到“路径”
C:\Program Files\Java\jdk1.8.0_91\jre\bin
(我在 Win10 上工作) - 利润。
Problem was on version 0.12.2 - 0.13.1 and it totally disappeared.
问题出在 0.12.2 - 0.13.1 版本上,它完全消失了。
回答by Fran?ois Dupire
回答by Francesco Pitzalis
Add
添加
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.2.11</version>
</dependency>
to your pom, it contains the missing class, with this I fixed it.
对于你的 pom,它包含缺少的类,我修复了它。