How to generate classes from wsdl using Maven and wsimport?

后端 未结 7 903
时光说笑
时光说笑 2020-12-01 00:35

When I attempt to run \"mvn generate-sources\" this is my output :

SLF4J: Failed to load class \"org.slf4j.impl.StaticLoggerBinder\".
SLF4J: Defaulting to n         


        
7条回答
  •  粉色の甜心
    2020-12-01 00:44

    I see some people prefer to generate sources into the target via jaxws-maven-plugin AND make this classes visible in source via build-helper-maven-plugin. As an argument for this structure

    the version management system (svn/etc.) would always notice changed sources

    With git it is not true. So you can just configure jaxws-maven-plugin to put them into your sources, but not under the target folder. Next time you build your project, git will not mark these generated files as changed. Here is the simple solution with only one plugin:

          
            org.codehaus.mojo
            jaxws-maven-plugin
            2.6
    
        
          
            org.jvnet.jaxb2_commons
            jaxb2-fluent-api
            3.0
          
          
            com.sun.xml.ws
            jaxws-tools
            2.3.0
          
        
    
        
          
            
              wsimport
            
            
              som.path.generated
              
                -Xfluent-api
              
              true
              true 
              ${project.build.sourceDirectory}
              src/main/resources/META-INF/wsdl
              META-INF/wsdl/soap.wsdl
            
          
        
      
    

    Additionally (just to note) in this example SOAP classes are generated with Fluent API, so you can create them like:

    A a = new A()
      .withField1(value1)
      .withField2(value2);
    

提交回复
热议问题