我想寫一個簡單的春天休息Web服務,因爲我不熟悉Maven(並且因爲Maven通常不能完成任務 - 連接問題),所以我現在嘗試構建Ant。現在,構建可以,服務可以運行。但是,如果持續功能被觸發時,系統會提示:實體管理器尚未注入:是將Spring Aspects JAR配置爲AJC/AJDT方面的庫嗎?
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)
我的螞蟻的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>
任何幫助將高度讚賞。謝謝!
「因爲Maven的平時不能做的事等」哈哈哈,你做了我的一天。你知道,成千上萬的軟件項目一直都在使用maven,所有這些都是世界的顛峯嗎?在過去的5年中,我沒有在一個單獨的項目中工作,而這個項目並不是由Maven構建的。 –
嗨肖恩,任何想法幫助?我的意思是我的網絡不好,maven需要從中央資源庫下載太多的工件。通過使用ant,我可以手動下載它們(使用多線程下載工具),所以速度很快。 –