ฉันต้องการใช้ Spring AOP ในแอปพลิเคชัน Spring ของฉัน ขณะสร้างพร็อกซี AOP สำหรับ net.sf.ehcache.CacheManager
การเตรียมใช้งานบริบทสปริงล้มเหลวโดยมีข้อยกเว้นด้านล่าง:
nested exception is org.springframework.aop.framework.AopConfigException: Could not
generate CGLIB subclass of class [class net.sf.ehcache.CacheManager]: Common causes of
this problem include using a final class or a non-visible class; nested exception is
net.sf.cglib.core.CodeGenerationException: net.sf.ehcache.CacheException-->Another
unnamed CacheManager already exists in the same VM. Please provide unique names for
each CacheManager in the config or do one of following:
1. Use one of the CacheManager.create() static factory methods to reuse same
CacheManager with same name or create one if necessary
2. Shutdown the earlier cacheManager before creating new one with same name.
The source of the existing CacheManager is: InputStreamConfigurationSource
[stream=java.io.ByteArrayInputStream@955b34]
นี่คือความเข้าใจของฉันเกี่ยวกับปัญหานี้ - Spring กำลังพยายามสร้างพร็อกซี AOP สำหรับ net.sf.ehcache.CacheManager
และประสบความสำเร็จในครั้งแรกและตั้งชื่อเริ่มต้นให้กับ CacheManager __DEFAULT__
(พบสิ่งนี้โดยการเพิ่มคำสั่ง debug ให้กับรหัส ehcache สร้างตามแหล่งที่มาและใช้งานนั้น ในใบสมัครของฉัน) ตอนนี้ถ้าฉันมีตัวจัดการแคชหลายตัวเช่น 'abcCacheManager' และ 'xyzCacheManager' (ประเภท EhCacheManagerFactoryBean) Spring จะพบ net.sf.ehcache.CacheManager
s หลายอันและพยายามสร้างวัตถุพร็อกซี (บางอย่างเช่น net.sf.ehcache.CacheManager$$EnhancerByCGLIB$$b18c5958
) สำหรับทั้งหมด แต่ด้วย EhCache >=2.5 เวอร์ชัน เราไม่สามารถมีแคชที่มีชื่อเดียวกันได้มากกว่าหนึ่งรายการภายใต้ VM เดียวกัน
ฉันใช้ EhCache 2.5.1 และต้องการหลีกเลี่ยงการกลับไปเป็น 2.4 เพียงเพื่อจุดประสงค์นี้ ฉันไม่แน่ใจว่านี่เป็นปัญหาจริงๆ หรือไม่ ฉันจะแก้ไขปัญหานี้ได้อย่างไร
หมายเหตุ: โปรดทราบว่าสิ่งนี้จะช่วยได้หรือไม่ แต่ฉันยังสังเกตเห็นจากคำสั่งแก้ไขข้อบกพร่องที่ CacheManager
no-arg Constructor ถูกเรียกใช้โดยตัวสร้างพร็อกซี spring/CGLIB เท่านั้น และ xyzCacheManager
เรียกใช้โดยส่งการกำหนดค่าเป็นอาร์กิวเมนต์
CacheManager
จริงๆ หรือไม่ - person jeha   schedule 10.09.2012