How does one get JAXB-generated sources onto the E

2019-01-31 21:05发布

Under Helios/m2eclipse, when I generated jaxb sources they would be put on the Eclipse source path when I did an "Update Project Configuration".

This doesn't happen with Indigo/m2e (initial release of 22 June 2011). What do I need to do to fix this?

I'm using the standard maven-jaxb2-plugin, version 0.75.

5条回答
乱世女痞
2楼-- · 2019-01-31 21:39

Well, you need to right click on the "target/generated-sources/xjc and select something like "Build Path -> Use as source folder"

查看更多
迷人小祖宗
3楼-- · 2019-01-31 21:53

In Eclipse go to "Install New Software" add the software site: http://bitstrings.github.com/m2e-connectors-p2/releases/

Select the "m2e connector for jaxb2"

Once you get that plugin installed the jaxb2 plugin should integrate correctly with the new version of m2e.

This info is from: https://bugs.eclipse.org/bugs/show_bug.cgi?id=350299

查看更多
手持菜刀,她持情操
4楼-- · 2019-01-31 21:56

As an alternate workaround if you can't get the m2e connector working, you can add the generated sources to the build path with build-helper-maven-plugin:

<build>
  ...
  <plugins>
    ...
    <plugin>
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>build-helper-maven-plugin</artifactId>
      <version>1.7</version>
      <executions>
        <execution>
          <id>add-source</id>
          <phase>generate-sources</phase>
          <goals>
            <goal>add-source</goal>
          </goals>
          <configuration>
            <sources>
              <source>target/generated-sources/xmlbeans</source>
            </sources>
          </configuration>
        </execution>
      </executions>
    </plugin>
    ...     
  </plugins>
  ... 
</build>
查看更多
疯言疯语
5楼-- · 2019-01-31 22:01

While waiting for a fix for this problem, I'm using the following temporary workaround:

We have the jaxb-plugin and generated classes in a separate maven module. In eclipse I can then "disable Maven nature" on that module only. Then I can use Indigo with m2eclipse on the rest of our large maven project and it will depend on the jar for the jaxb module (must be built from the command line). This works well for me since our project was allready organized this way.

查看更多
Explosion°爆炸
6楼-- · 2019-01-31 22:03

For those who are suffering with maven-jaxb2-plugin and Eclipse not having source attached. The author has switched from the Sun to the Glassfish JAXB artifacts and the dependency tree has changed. Previously many JARs where shaded into jaxb-xjc without transitive ones. Now, this has been removed and the previous transitive dependency to tools.jar breaks Eclipse execution. Start your Eclipse with a JDK VM and it will work. (Tested most recent Maven 3.3.9, Maven JAXB2 Plugin 0.13.1, recent m2e JAXB2 connector and Eclipse Mars.2)

查看更多
登录 后发表回答