2016-03-14 45 views
1

我知道Hyperjaxb3库对我的项目非常有用,可以在多个站点上阅读一些描述,并决定将它嵌入到我的Spring-Hibernate项目中。HyperJaxb3项目发生了什么?

我发现https://jaxb.java.net/中的Hyperjaxb3的引用很正式,但超链接 - http://confluence.highsource.org/display/HJ3/Home - 未打开。

我发现了一些旧的POM示例,将其包含到我的项目中,并找到了一些旧版本引用,试图消除它们,但现在看来我碰到了旧Hibernate版本的依赖关系,错误是这样的:

java.util.ServiceConfigurationError:com.sun.tools.xjc.Plugin:提供org.jvnet.hyperjaxb3.hibernate.plugin.HibernatePlugin无法实例:java.lang.NoClassDefFoundError:组织/休眠/类型/ MutableType

我想知道是否有更好的Maven条目,如果项目是活着的,我如何与Moder Hibernate一起使用它。

这是我对Hyperjaxb3,在那里我排除一些过时的链接,并指定其他依赖的最新版本POM摘录:

<dependency> 
     <groupId>org.glassfish.jaxb</groupId> 
     <artifactId>jaxb-core</artifactId> 
     <version>${jaxb-version}</version> 
    </dependency>   
    <dependency> 
     <groupId>org.glassfish.jaxb</groupId> 
     <artifactId>jaxb-xjc</artifactId> 
     <version>${jaxb-version}</version> 
    </dependency> 
    <!--<dependency> 
     <groupId>org.jvnet.hyperjaxb3</groupId> 
     <artifactId>hyperjaxb3</artifactId> 
     <version>0.6.1</version> 
    </dependency>  --> 
    <dependency> 
     <groupId>org.jvnet.hyperjaxb3</groupId> 
     <artifactId>hyperjaxb3-hibernate-plugin</artifactId> 
     <version>0.1</version> 
     <exclusions> 
      <exclusion> 
       <groupId>hsqldb</groupId> 
       <artifactId>hsqldb</artifactId> 
      </exclusion> 
      <exclusion> 
       <groupId>junit</groupId> 
       <artifactId>junit</artifactId> 
      </exclusion> 
      <exclusion> 
       <groupId>log4j</groupId> 
       <artifactId>log4j</artifactId> 
      </exclusion> 
      <exclusion> 
       <groupId>net.sf.saxon</groupId> 
       <artifactId>saxon</artifactId> 
      </exclusion> 
      <exclusion> 
       <groupId>net.sf.saxon</groupId> 
       <artifactId>saxon-dom</artifactId> 
      </exclusion> 
      <exclusion> 
       <groupId>org.hibernate</groupId> 
       <artifactId>hibernate</artifactId> 
      </exclusion> 
      <exclusion> 
       <groupId>org.springframework</groupId> 
       <artifactId>spring</artifactId> 
      </exclusion> 
      <exclusion> 
       <groupId>com.sun.xml.bind</groupId> 
       <artifactId>jaxb-xjc</artifactId> 
      </exclusion> 
     </exclusions> 
    </dependency> 
    <dependency> 
     <groupId>asm</groupId> 
     <artifactId>asm</artifactId> 
     <version>3.3.1</version> 
    </dependency> 
    <dependency> 
     <groupId>asm</groupId> 
     <artifactId>asm-attrs</artifactId> 
     <version>2.2.3</version> 
    </dependency> 
    <dependency> 
     <groupId>cglib</groupId> 
     <artifactId>cglib</artifactId> 
     <version>3.2.1</version> 
    </dependency> 

    <dependency> 
     <groupId>commons-beanutils</groupId> 
     <artifactId>commons-beanutils</artifactId> 
     <version>1.9.2</version> 
    </dependency> 
    <dependency> 
     <groupId>commons-lang</groupId> 
     <artifactId>commons-lang</artifactId> 
     <version>2.6</version> 
    </dependency> 
    <dependency> 
     <groupId>commons-logging</groupId> 
     <artifactId>commons-logging</artifactId> 
     <version>1.2</version> 
    </dependency> 

我目前没有试图生成注解Hibernate的实体类,但是从的POJO PurchaseOdrer示例。这是我目前做的:

public void initializeModel(String name, InputStream src, String dir) throws IOException, URISyntaxException{ 
    dir = Paths.get(new URL(dir).toURI()).toString(); 
    File directory = new File(dir); 
    directory.mkdirs(); 

    SchemaCompiler sc = XJC.createSchemaCompiler(); 
    sc.setDefaultPackageName(this.getClass().getPackage().getName() + ".generated"); 

    InputSource is = new InputSource(src); 
    is.setSystemId(name); 

    sc.parseSchema(is); 
    S2JJAXBModel model = sc.bind(); 
    JCodeModel codeModel = model.generateCode(null, null); 

    CodeWriter cw = new FileCodeWriter(directory);   
    codeModel.build(cw); 
} 

回答

4

免责声明:我Hyperjaxb3的作者。

该项目托管在GitHub上:

最新版本0.6.1是功能性的,可以作为它应该。

但是,我不再积极地开发它。

Will it work with the current version of hibernate?

版本0.6.1的作品是用Hibernate 4.1.7进行测试的。 HJ3只是一个生成标准JPA注释类的代码生成器。所以很有可能它会与最新版本的Hibernate一起工作。

I just can't get the 0.6.1 jar from Maven. Seems like it was eliminated from maven repositories.

真的吗?还在那儿。

http://repo1.maven.org/maven2/org/jvnet/hyperjaxb3/hyperjaxb3-ejb-plugin/0.6.1/

An I don't understand if I need the "hyperjaxb3-hibernate-plugin" 0.1 from the year 2011.

你绝对不。

Or do you aware of any fork or an analog?

不幸的是,没有结果。

+0

谢谢!几个问题,对不起。它会与当前版本的hibernate一起工作吗? – fedd

+0

这很有趣。我只是无法从Maven获得0.6.1 jar。似乎它从maven仓库中被淘汰。我不明白我是否需要2011年的“hyperjaxb3-hibernate-plugin”0.1。 还是你知道有任何叉子或模拟?谢谢! – fedd

+1

@fedd查看更新。 – lexicore