这是我第一次使用Maven,我正在尝试从WSDL生成客户端。 我创建了一个Maven项目,并从类似的项目中下载了一个pom.xml文件,然后我运行了mvn assembly:assembly命令构建以生成存根,但编译不起作用并且它产生错误。
这是我的pom.xml文件
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.logicsector</groupId>
<artifactId>weather-client</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>SOAP weather client</name>
<dependencies>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>2.1.2</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>2.1.2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.5.2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.5.2</version>
</dependency>
</dependencies>
<build>
<finalName>weather-client</finalName>
<plugins>
<!-- Generate Java classes from WSDL during build -->
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>2.1.2</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>${basedir}/target/generated/src/main/java</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/src/main/wsdl/weather.wsdl</wsdl>
<extraargs>
<extraarg>-client</extraarg>
</extraargs>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Add generated sources - avoids having to copy generated sources to build location -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${basedir}/target/generated/src/main/java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<!-- Build the JAR with dependencies -->
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
<!-- Build with Java 1.5 -->
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
这是我得到的错误
[INFO]扫描项目... [警告] [警告]一些问题 在构建有效模型时遇到了 com.logicsector:weather-client:jar:0.0.1-SNAPSHOT [警告] &#39; build.plugins.plugin.version&#39;对于 org.codehaus.mojo:缺少build-helper-maven-plugin。 @第61行, 第21栏[警告] [警告]强烈建议您修理这些 问题,因为它们威胁到你的构建的稳定性。 [警告] [警告]因此,未来的Maven版本可能不再存在 支持建立这样的畸形项目。 [警告] [信息]
[信息] -------------------------------------------------- ---------------------- [INFO]构建SOAP天气客户端0.0.1-SNAPSHOT [INFO] -------------------------------------------------- ---------------------- [INFO] [INFO]&gt;&gt;&gt;行家组装-插件:2.2-β-5:装配 (default-cli)@ weather-client&gt;&gt;&gt; [INFO] [INFO] --- cxf-codegen-plugin:2.1.2:wsdl2java(generate-sources)@weather-client --- mars 23,2015 3:11:05 PM org.springframework.context.support.AbstractApplicationContext prepareRefresh INFO:刷新 org.apache.cxf.bus.spring.BusApplicationContext@466d9e6c:显示名称 [org.apache.cxf.bus.spring.BusApplicationContext@466d9e6c];启动 日期[Mon Mar 23 15:11:05 GMT + 01:00 2015];上下文层次结构的根 mars 23,2015 3:11:05 PM org.apache.cxf.bus.spring.BusApplicationContext getConfigResources 信息:未检测到cxf.xml配置文件,依赖于默认值。 mars 23,2015 3:11:05 PM org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory INFO:应用程序上下文的Bean工厂 [org.apache.cxf.bus.spring.BusApplicationContext@466d9e6c]: org.springframework.beans.factory.support.DefaultListableBeanFactory@7f85e8ac mars 23,2015 3:11:06 PM org.springframework.context.support.AbstractApplicationContext $ BeanPostProcessorChecker postProcessAfterInitialization INFO:Bean &#39; org.apache.cxf.bus.spring.Jsr250BeanPostProcessor&#39;不符合条件 由所有BeanPostProcessors处理(例如:不 有资格进行自动代理)mars 23,2015 3:11:06 PM org.springframework.context.support.AbstractApplicationContext $ BeanPostProcessorChecker postProcessAfterInitialization INFO:Bean &#39; org.apache.cxf.bus.spring.BusExtensionPostProcessor&#39;不符合条件 由所有BeanPostProcessors处理(例如:不 有资格进行自动代理)mars 23,2015 3:11:06 PM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons信息:预先实例化单例 org.springframework.beans.factory.support.DefaultListableBeanFactory@7f85e8ac: 定义bean [CXF,org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor,org.apache.cxf.bus.spring.Jsr250BeanPostProcessor,org.apache.cxf.bus.spring.BusExtensionPostProcessor,org.apache.cxf.resource.ResourceManager,组织.apache.cxf.configuration.Configurer,org.apache.cxf.binding.BindingFactoryManager,org.apache.cxf.transport.DestinationFactoryManager,org.apache.cxf.transport.ConduitInitiatorManager,org.apache.cxf.wsdl.WSDLManager,组织.apache.cxf.phase.PhaseManager,org.apache.cxf.workqueue.WorkQueueManager,org.apache.cxf.buslifecycle.BusLifeCycleManager,org.apache.cxf.endpoint.ServerRegistry,org.apache.cxf.endpoint.ServerLifeCycleManager,组织.apache.cxf.endpoint.ClientLifeCycleManager,org.apache.cxf.transports.http.QueryHandlerRegistry,org.apache.cxf.endpoint.EndpointResolverRegistry,org.apache.cxf.headers.HeaderManager,org.apache.cxf.catalog.OASISCatalogManager ,org.apache.cxf.endpoint.ServiceContractResolverRegistry,org.apache.cxf.jaxws.context.WebServiceContextResourceResolver,org.apache.cxf.jaxw s.context.WebServiceContextImpl,org.apache.cxf.binding.soap.SoapBindingFactory,org.apache.cxf.binding.soap.SoapTransportFactory,org.apache.cxf.binding.soap.customEditorConfigurer,org.apache.cxf.binding。 xml.XMLBindingFactory,org.apache.cxf.ws.addressing.policy.AddressingAssertionBuilder,org.apache.cxf.ws.addressing.policy.AddressingPolicyInterceptorProvider,org.apache.cxf.ws.addressing.policy.UsingAddressingAssertionBuilder,org.apache。 cxf.transport.http.policy.HTTPClientAssertionBuilder,org.apache.cxf.transport.http.policy.HTTPServerAssertionBuilder,org.apache.cxf.transport.http.policy.NoOpPolicyInterceptorProvider,org.apache.cxf.transport.http.ClientOnlyHTTPTransportFactory] ; 工厂等级的根源火星23,2015 3:11:10 PM org.springframework.context.support.AbstractApplicationContext doClose 信息:结束 org.apache.cxf.bus.spring.BusApplicationContext@466d9e6c:显示名称 [org.apache.cxf.bus.spring.BusApplicationContext@466d9e6c];启动 日期[Mon Mar 23 15:11:05 GMT + 01:00 2015];上下文层次结构的根 mars 23,2015 3:11:10 PM org.springframework.beans.factory.support.DefaultSingletonBeanRegistry destroySingletons信息:摧毁单身人士 org.springframework.beans.factory.support.DefaultListableBeanFactory@7f85e8ac: 定义bean [CXF,org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor,org.apache.cxf.bus.spring.Jsr250BeanPostProcessor,org.apache.cxf.bus.spring.BusExtensionPostProcessor,org.apache.cxf.resource.ResourceManager,组织.apache.cxf.configuration.Configurer,org.apache.cxf.binding.BindingFactoryManager,org.apache.cxf.transport.DestinationFactoryManager,org.apache.cxf.transport.ConduitInitiatorManager,org.apache.cxf.wsdl.WSDLManager,组织.apache.cxf.phase.PhaseManager,org.apache.cxf.workqueue.WorkQueueManager,org.apache.cxf.buslifecycle.BusLifeCycleManager,org.apache.cxf.endpoint.ServerRegistry,org.apache.cxf.endpoint.ServerLifeCycleManager,组织.apache.cxf.endpoint.ClientLifeCycleManager,org.apache.cxf.transports.http.QueryHandlerRegistry,org.apache.cxf.endpoint.EndpointResolverRegistry,org.apache.cxf.headers.HeaderManager,org.apache.cxf.catalog.OASISCatalogManager ,org.apache.cxf.endpoint.ServiceContractResolverRegistry,org.apache.cxf.jaxws.context.WebServiceContextResourceResolver,org.apache.cxf.jaxw s.context.WebServiceContextImpl,org.apache.cxf.binding.soap.SoapBindingFactory,org.apache.cxf.binding.soap.SoapTransportFactory,org.apache.cxf.binding.soap.customEditorConfigurer,org.apache.cxf.binding。 xml.XMLBindingFactory,org.apache.cxf.ws.addressing.policy.AddressingAssertionBuilder,org.apache.cxf.ws.addressing.policy.AddressingPolicyInterceptorProvider,org.apache.cxf.ws.addressing.policy.UsingAddressingAssertionBuilder,org.apache。 cxf.transport.http.policy.HTTPClientAssertionBuilder,org.apache.cxf.transport.http.policy.HTTPServerAssertionBuilder,org.apache.cxf.transport.http.policy.NoOpPolicyInterceptorProvider,org.apache.cxf.transport.http.ClientOnlyHTTPTransportFactory] ; 工厂层级的根[INFO] -------------------------------------------------- ---------------------- [INFO] BUILD FAILURE [INFO] -------------------------------------------------- ---------------------- [INFO]总时间:9.122s [INFO]完成时间:3月23日星期一15:11:10 GMT + 01:00 2015 [INFO]最终记忆:21M / 311M [INFO] -------------------------------------------------- ---------------------- [错误]无法执行目标 org.apache.cxf:cxf-codegen-plugin:2.1.2:wsdl2java(generate-sources) on project weather-client:执行生成 - 目标来源 org.apache.cxf:cxf-codegen-plugin:2.1.2:wsdl2java失败:非法 索引2处不透明部分的字符: D:\ gireveWorkSpace \ weather-client / src / main / wsdl / weather.wsdl - &gt; [救命 1] [ERROR] [ERROR]要查看错误的完整堆栈跟踪,请重新运行 使用-e开关的Maven。 [错误]使用-X开关重新运行Maven 启用完整调试日志记录[错误] [错误]有关的更多信息 错误和可能的解决方案,请阅读以下文章: [错误] [帮助1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
我正在使用Eclipse Juno并且我成功配置了Maven,您能帮我找到解决方案吗?
答案 0 :(得分:2)
你可以在pom.xml下面使用
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.logicsector</groupId>
<artifactId>weather-client</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>SOAP weather client</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<cxf.version>2.7.5</cxf.version>
<slfj.version>1.7.5</slfj.version>
<jdk.version>1.6</jdk.version>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slfj.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${slfj.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
<version>${slfj.version}</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<versionRange>[2.7,)</versionRange>
<goals>
<goal>wsdl2java</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf.version}</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>${basedir}/target/generated/src/main/java</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/src/main/resources/wsdl/weather.wsdl</wsdl>
<wsdlLocation>classpath:wsdl/ServiceManagement.wsdl</wsdlLocation>
<extraargs>
<extraarg>-verbose</extraarg>
<extraarg>-client</extraarg>
</extraargs>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Maven compiler -->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
您可以根据需求和属性标记中的jdk版本更改cxf版本。虽然您正在谈论的版本是maven eclipse插件(m2e),但是eclipse支持maven版本3,而且更多依赖于maven版本。
另一点值得注意的是目录结构,配置中的wsdl目录在classpath之外。默认情况下,在maven中src/main/java
,src/main/resources
是类路径(在打包期间也会考虑这一点)。因此修改了你的cxf插件配置