3

私はmavenに慣れていないので(そして、mavenは通常、接続の問題を解決できないため)、単純なSpring Rest Webサービスを作成しようとしているので、現在antビルドを試みています。これで、ビルドは問題なく、サービスを実行できます。ただし、永続関数がトリガーされると、プロンプトが表示されます。

 01:48:39 Handler execution resulted in exception - forwarding to resolved error view: ModelAndView: reference to view with name 'uncaughtException'; model is {exception=java.lang.IllegalStateException: Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)} -org.springframework.web.servlet.DispatcherServlet
 java.lang.IllegalStateException: Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)
    at com.books.domain.UserInfo.entityManager(UserInfo.java:96)
    at com.books.domain.UserInfo.findUserByNamePassword(UserInfo.java:157)
    at com.books.web.UserController.register(UserController.java:28)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:213)
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126)
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578)

私のant build.xml:

<target name="compile" depends="init" description="compile the source ">
    <!--<javac srcdir="${src}" 
    debug="on"
    destdir="${build}" 
    classpathref="compile.classpath"
    includeantruntime="false"/>-->
    <iajc source ="1.6" target="1.6" sourceroots="src/main/java" destDir="src/main/webapp/WEB-INF/classes" showweaveinfo="true" verbose="true">
        <classpath>
            <path refid="compile.classpath"/>
            <path refid="aspectj.classpath"/>
        </classpath>
    </iajc>
</target>

私のapplicationContext.xml:

<bean class="org.springframework.orm.jpa.JpaTransactionManager" id="transactionManager">
    <property name="entityManagerFactory" ref="entityManagerFactory"/>
</bean>
<tx:annotation-driven mode="aspectj" transaction-manager="transactionManager"/>
<bean class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" id="entityManagerFactory">
    <property name="dataSource" ref="dataSource"/>
</bean>

どんな助けでも大歓迎です。ありがとう!

4

3 に答える 3

4

私は解決策を見つけました:

これは正しいiajcタスクです

<iajc source ="1.6" target="1.6" sourceroots="src/main/java" destDir="src/main/webapp/WEB-INF/classes" showweaveinfo="true" verbose="true">
    <classpath>
        <path refid="compile.classpath"/>
        <path refid="aspectj.classpath"/>
    </classpath>
    <aspectpath>
         <pathelement location="${workdir}/WEB-INF/lib/spring-aspects-3.2.6.RELEASE.jar" />
    </aspectpath>
</iajc>
于 2014-03-19T13:55:19.923 に答える
1

Roo への切り替えは実際には解決策ではなく回避策であることを考慮して、この問題に関する私の経験を共有したいと思います。

確認する必要があるのは次の 2 点です。

  1. あなたは、aspectj を介してクラスをコンパイルする必要があります。Maven のspectjプラグインは、この要件を提供します。
  2. エンティティ クラスに注釈を付ける必要があります@Configurable
于 2013-09-18T22:00:51.220 に答える
1

ROO と maven pom を使用して、この問題を解決しました。Ant ビルドの使用方法に関する情報が少なすぎます。

于 2012-06-20T02:05:35.920 に答える