@带有SpEL的CacheReceive注释在Eclipse编译之后工作,但在Ant编译之后不工作 问题
我有一个使用Spring@cacheexecute注释和嵌入式Spring表达式语言的类。当我允许Eclipse自动编译这个类时,一切都很好。但是,当我使用Ant任务(通过Eclipse或从命令行)编译时,生成的.class文件不起作用,并抛出一个异常,这看起来像是在转移注意力 我的问题:如何配置Ant构建,使其生成工作类工件(以便其他开发人员可以在不需要Eclipse的情况下构建我的项目)?Eclipse和Ant之间的配置似乎是相同的,但我肯定在某些地方缺少了一些属性 版本@带有SpEL的CacheReceive注释在Eclipse编译之后工作,但在Ant编译之后不工作 问题,eclipse,spring,ant,Eclipse,Spring,Ant,我有一个使用Spring@cacheexecute注释和嵌入式Spring表达式语言的类。当我允许Eclipse自动编译这个类时,一切都很好。但是,当我使用Ant任务(通过Eclipse或从命令行)编译时,生成的.class文件不起作用,并抛出一个异常,这看起来像是在转移注意力 我的问题:如何配置Ant构建,使其生成工作类工件(以便其他开发人员可以在不需要Eclipse的情况下构建我的项目)?Eclipse和Ant之间的配置似乎是相同的,但我肯定在某些地方缺少了一些属性 版本 Ant(与Ecl
- Ant(与Eclipse捆绑):org.apache.Ant_1.8.3.v20120321-1730
- Eclipse:Juno服务版本120120920-0800
- JDK:1.7.0_17
- JUnit:4.10(in/lib/of项目)
- 操作系统:Windows 7 64位
- 春季:3.2.2
package sample;
import org.springframework.cache.annotation.CacheEvict;
public class SampleAction {
@CacheEvict(value = "sampleCache", allEntries = true, condition = "#string.bytes != null")
public void triggerCache(String string) {
System.out.println("triggerCache(" + string + ")");
}
}
/src/sample/SampleActionTest.java:一种单元测试,可用于Eclipse工件,但无法用于Ant工件
package sample;
import org.junit.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={"application.xml"})
public class SampleActionTest {
@Autowired
private SampleAction sampleAction;
@Test
public void testCacheMethod() {
sampleAction.triggerCache("Definitely not a null string.");
}
}
/src/sample/application.xml:缓存和操作类的Spring定义文件
<cache:annotation-driven />
<bean id="sampleAction" class="sample.SampleAction" />
<bean id="cacheManager" class="org.springframework.cache.support.SimpleCacheManager">
<property name="caches">
<set>
<bean class="org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean" p:name="sampleCache" />
</set>
</property>
</bean>
/build.xml:清除、编译并运行失败的单元测试的Ant构建
<path id="classpath.main">
<fileset dir="lib" includes="*.jar" />
</path>
<path id="classpath.test">
<path refid="classpath.main" />
<pathelement location="output/classes" />
</path>
<target name="compileFailure" description="Cleans, compiles, and runs a unit test, which fails.">
<delete quiet="true" dir="output/classes" />
<mkdir dir="output/classes" />
<copy tofile="output/classes/sample/application.xml" file="src/sample/application.xml" />
<javac srcdir="src" destdir="output/classes"
classpathref="classpath.main" source="1.6" target="1.6" includeantruntime="false" />
<junit printsummary="yes">
<classpath refid="classpath.test" />
<formatter type="plain" usefile="false"/>
<test name="sample.SampleActionTest" outfile="result" />
</junit>
</target>
此存根项目还可以作为ZIP存档提供,包括Spring和JUnit的支持JAR文件:
复制步骤
<javac debug="true" [...] />
似乎SpEL需要java编译器来设置类文件中的调试信息才能工作。在启用maven build中生成的调试信息后,我遇到了一个问题。Eclipse编译器会自动执行此操作。似乎SpEL需要java编译器来设置类文件中的调试信息才能正常工作。在启用maven build中生成的调试信息后,我遇到了一个问题。Eclipse编译器会自动执行此操作。这正是问题所在!这正是问题所在!
com.springsource.org.aopalliance-1.0.0.jar
commons-logging-1.1.3.jar
junit-4.10.jar
spring-aop-3.2.2.jar
spring-beans-3.2.2.jar
spring-context-3.2.2.jar
spring-context-support-3.2.2.jar
spring-core-3.2.2.jar
spring-expression-3.2.2.jar
spring-test-3.2.2.jar
<javac debug="true" [...] />