0

学習目的のCRUDデモプロジェクトでstruts2-fullhibernatecore-plugin-2.2.2-GAに苦労しています。以下は私が得るエラーであり、さまざまな休止状態の依存関係がそれを機能させようとしました。下記参照

エラー

java.lang.NoSuchMethodError: org.hibernate.SessionFactory.openSession()Lorg/hibernate/classic/Session;
    com.googlecode.s2hibernate.struts2.plugin.util.HibernateSessionFactory.createAndTestSessionFactory(HibernateSessionFactory.java:284)
    com.googlecode.s2hibernate.struts2.plugin.util.HibernateSessionFactory.rebuildSessionFactory(HibernateSessionFactory.java:227)
    com.googlecode.s2hibernate.struts2.plugin.util.HibernateSessionFactory.getNewSession(HibernateSessionFactory.java:155)

このスレッドの回答からわかります ここをクリック

プラグインで動作する休止状態のバージョンを確認するために、さまざまなMaven依存関係を開始して、

以下のバージョンから機能しない

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-core</artifactId>
    <version>4.1.6.Final</version>
</dependency>

このバージョンまで動作します

  <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>3.6.10.Final</version>
        </dependency>

質問:明らかにHibernate3を使用したくないので、struts2-fullhibernatecore-plugin-2.2.2-GAで最新のhibernate4 +を使用できる方法はありますか?

質問: struts2の休止状態で最も広く使用されているDIは何ですか。上記のプラグインが機能しない場合は、Springまたはgoogleジュースを使用する必要がありますか?ビューパターンを除いて、休止状態のセッションを管理するための他の実行可能なソリューションはありませんが、そのアンチパターンと言って、多くの欠点があります。

4

1 に答える 1

0

この設定を使用します

<plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>hibernate3-maven-plugin</artifactId>
                <version>2.2</version>
                <configuration>
                    <components>
                        <component>
                            <name>hbm2ddl</name>
                            <implementation>jpaconfiguration</implementation>
                        </component>
                    </components>
                    <componentProperties>
                        <outputfilename>schema.ddl</outputfilename>
                        <create>true</create>
                        <export>false</export>
                        <format>true</format>
                        <drop>true</drop>
                        <jdk5>true</jdk5>
                        <propertyfile>target/test-classes/jdbc.properties</propertyfile>
                        <skip>${skipTests}</skip>
                    </componentProperties>
                </configuration>
                <!--<executions>-->
                <!--<execution>-->
                <!--<phase>process-test-resources</phase>-->
                <!--<goals>-->
                <!--<goal>hbm2ddl</goal>-->
                <!--</goals>-->
                <!--</execution>-->
                <!--</executions>-->
                <dependencies>
                    <dependency>
                        <groupId>org.hibernate</groupId>
                        <artifactId>hibernate-entitymanager</artifactId>
                        <version>${hibernate.maven.plugin.version}</version>
                        <exclusions>
                            <exclusion>
                                <groupId>cglib</groupId>
                                <artifactId>cglib</artifactId>
                            </exclusion>
                            <exclusion>
                                <groupId>commons-logging</groupId>
                                <artifactId>commons-logging</artifactId>
                            </exclusion>
                        </exclusions>
                    </dependency>
                    <dependency>
                        <groupId>org.hibernate</groupId>
                        <artifactId>hibernate-core</artifactId>
                        <version>${hibernate.maven.plugin.version}</version>
                        <exclusions>
                            <exclusion>
                                <groupId>cglib</groupId>
                                <artifactId>cglib</artifactId>
                            </exclusion>
                            <exclusion>
                                <groupId>commons-logging</groupId>
                                <artifactId>commons-logging</artifactId>
                            </exclusion>
                        </exclusions>
                    </dependency>
                    <dependency>
                        <groupId>org.hibernate</groupId>
                        <artifactId>hibernate-validator</artifactId>
                        <version>4.2.0.Final</version>
                    </dependency>
                    <dependency>
                        <groupId>${jdbc.groupId}</groupId>
                        <artifactId>${jdbc.artifactId}</artifactId>
                        <version>${jdbc.version}</version>
                    </dependency>
                </dependencies>
            </plugin>

<hibernate.maven.plugin.version>3.6.10.Final</hibernate.maven.plugin.version>pom プロパティに追加します。

于 2012-10-27T10:36:01.827 に答える