{"id":445664,"date":"2021-04-19T18:45:39","date_gmt":"2021-04-19T10:45:39","guid":{"rendered":"http:\/\/4563.org\/?p=445664"},"modified":"2021-04-19T18:45:39","modified_gmt":"2021-04-19T10:45:39","slug":"%e5%b7%b2%e8%a7%a3%e5%86%b3-%e5%a6%82%e4%bd%95%e5%9c%a8-spring-%e6%a1%86%e6%9e%b6%e4%b8%ad%e4%bd%bf%e7%94%a8-aspectj-%e8%bf%9b%e8%a1%8c%e5%8a%a0%e8%bd%bd%e6%97%b6%e7%bc%96%e7%bb%87%ef%bc%9f","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=445664","title":{"rendered":"[\u5df2\u89e3\u51b3] \u5982\u4f55\u5728 Spring \u6846\u67b6\u4e2d\u4f7f\u7528 AspectJ \u8fdb\u884c\u52a0\u8f7d\u65f6\u7f16\u7ec7\uff1f"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  [\u5df2\u89e3\u51b3] \u5982\u4f55\u5728 Spring \u6846\u67b6\u4e2d\u4f7f\u7528 AspectJ \u8fdb\u884c\u52a0\u8f7d\u65f6\u7f16\u7ec7\uff1f               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Kasumi20 <\/span>  <span><i><\/i> 7<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u8fd9\u65b9\u9762\u7684\u8d44\u6599\u5b9e\u5728\u662f\u592a\u5c11\u4e86\uff0c\u5b98\u65b9\u6587\u6863\u7814\u7a76\u4e86\u51e0\u5929\uff0c\u8e29\u4e86\u597d\u591a\u5751\u3002\u3002\u3002\u6ca1\u641e\u5b9a \u6709\u6ca1\u6709\u8e29\u8fc7\u5751\u7684\u5927\u4f6c<\/p>\n<p>\u4f7f\u7528 @EnableLoadTimeWeaving \u6ce8\u89e3\u914d\u7f6e\u7c7b\uff0c\u63d0\u4f9b\u4e00\u4e2a<code>InstrumentationLoadTimeWeaver<\/code> bean\uff0c \u7136\u540e\u8001\u662f\u629b\u5f02\u5e38<\/p>\n<pre><code>Caused by: java.lang.IllegalStateException: Must start with Java agent to use InstrumentationLoadTimeWeaver. See Spring documentation. <\/code><\/pre>\n<p>\u660e\u660e Gradle \u5df2\u7ecf\u8bbe\u7f6e\u4e86 VM \u9009\u9879\uff1a<\/p>\n<pre><code>-javaagent:\/home\/XXX\/spring-instrument-5.2.0.RELEASE.jar <\/code><\/pre>\n<p>\u597d\u70e6\u554a\uff01<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>3<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"5653006\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : hantsy <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u9ed8\u8ba4\u662f Runtime \u3002<\/p>\n<p>\u53ef\u4ee5\u8bbe\u7f6e\u6210 LoadTime \u548c Compile Time \uff08\u9700\u8981 AspectJ Compiler \u652f\u6301\uff09\u3002<\/p>\n<p>Spring \u5f15\u5165 ApsectJ \u7b80\u76f4\u662f\u707e\u96be\u3002<\/p>\n<p>\u539f\u6709\u7684 AOP alliance \u51e0\u4e2a\u7b80\u5355\u7684\u63a5\u53e3\u5df2\u7ecf\u591f\u7528\u4e86\u3002                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5653007\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : Kasumi20 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @hantsy <br \/>@Configuable \u8fd8\u662f\u5f88\u6709\u7528\u7684\uff0c\u95ee\u9898\u5df2\u7ecf\u89e3\u51b3\u4e86\uff0c\u5e94\u8be5\u8bbe\u7f6e gradle \u811a\u672c\uff1a<\/p>\n<p>test {<br \/> jvmArgs(&#8220;-javaagent:\/home\/XXX\/spring-instrument-5.2.0.RELEASE.jar&#8221;)<br \/> useJUnitPlatform()<br \/>}                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5653008\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : hantsy <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             Spring \u4e4b\u524d\u6709\u4e00\u4e2a Spring Roo \u9879\u76ee\uff08 Spring Boot \u51fa\u6765\u540e\u653e\u5f03\u4e86\uff09\uff0c\u5927\u91cf\u4f7f\u7528 AspectJ \u7279\u6027\uff0c\u652f\u6301 ROR \u5f0f\u7684\u5145\u8840\u6a21\u578b\uff0c\u6240\u4ee5 JPA Entity \u90fd\u662f @Configurable \u7f16\u8bd1\u65f6\u652f\u6301\u6ce8\u5165\u7684\u3002<\/p>\n<p>https:\/\/github.com\/hantsy\/spring-sandbox\/wiki\/Create-A-Cloud-Ready-Spring-Project-with-Roo                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>[\u5df2\u89e3\u51b3] \u5982\u4f55\u5728 Spring &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/445664"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=445664"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/445664\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=445664"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=445664"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=445664"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}