{"id":35149,"date":"2024-11-26T11:27:11","date_gmt":"2024-11-26T03:27:11","guid":{"rendered":"https:\/\/fwq.ai\/blog\/35149\/"},"modified":"2024-11-26T11:27:11","modified_gmt":"2024-11-26T03:27:11","slug":"%e7%ba%bf%e7%a8%8b%e7%b1%bb%e6%97%a0%e6%b3%95%e6%b3%a8%e5%85%a5redis%e6%88%96%e6%8e%a5%e5%8f%a3%ef%bc%9f%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8%e6%9e%84%e9%80%a0%e6%b3%a8%e5%85%a5%e8%a7%a3%e5%86%b3","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/35149\/","title":{"rendered":"\u7ebf\u7a0b\u7c7b\u65e0\u6cd5\u6ce8\u5165Redis\u6216\u63a5\u53e3\uff1f\u5982\u4f55\u4f7f\u7528\u6784\u9020\u6ce8\u5165\u89e3\u51b3\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173062351965300.jpg\" class=\"aligncenter\" title=\"\u7ebf\u7a0b\u7c7b\u65e0\u6cd5\u6ce8\u5165Redis\u6216\u63a5\u53e3\uff1f\u5982\u4f55\u4f7f\u7528\u6784\u9020\u6ce8\u5165\u89e3\u51b3\uff1f\u63d2\u56fe\" alt=\"\u7ebf\u7a0b\u7c7b\u65e0\u6cd5\u6ce8\u5165Redis\u6216\u63a5\u53e3\uff1f\u5982\u4f55\u4f7f\u7528\u6784\u9020\u6ce8\u5165\u89e3\u51b3\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u7ebf\u7a0b\u7c7b\u6ce8\u5165\u95ee\u9898\uff1a\u65e0@autowired\u6ce8\u5165\u65b9\u6cd5<\/strong><\/p>\n<p>\u4f60\u5728\u7f16\u5199\u7ebf\u7a0b\u7c7b\u65f6\u9047\u5230\u65e0\u6cd5\u6ce8\u5165  \u6216\u63a5\u53e3\u7684\u95ee\u9898\u3002\u8fd9\u662f\u56e0\u4e3a\u7ebf\u7a0b\u65e0\u6cd5\u4f7f\u7528@autowired\u8fdb\u884c\u6ce8\u5165\u3002\u4ee5\u4e0b\u662f\u5982\u4f55\u4f7f\u7528\u6784\u9020\u6ce8\u5165\u65b9\u6cd5\u89e3\u51b3\u6b64\u95ee\u9898\uff1a<\/p>\n<p><strong>\u7ebf\u7a0b\u7c7b\uff1a<\/strong><\/p>\n<pre>@component\npublic class mythread extends thread {\n\n    private redistemplate&lt;string, string&gt; redistemplate;\n    private myinterface myinterface;\n\n    public mythread(redistemplate&lt;string, string&gt; redistemplate, myinterface myinterface) {\n        this.redistemplate = redistemplate;\n        this.myinterface = myinterface;\n    }\n    ...\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u8c03\u7528\uff1a<\/strong><\/p>\n<pre>\/\/ \u6ce8\u5165\u7ebf\u7a0b\u7c7b\n@autowired\nprivate mythread mythread;\n\n\/\/ \u542f\u52a8\u7ebf\u7a0b\nmythread.start();<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u6ce8\u5165\uff1a<\/strong><\/p>\n<p>\u4f7f\u7528\u4ee5\u4e0b\u914d\u7f6e\u5728\u4e3b\u5e94\u7528\u7a0b\u5e8f\u4e0a\u4e0b\u6587\u4e2d\u914d\u7f6e\u8fd9\u4e09\u4e2a bean\uff1a<\/p>\n<pre>&lt;bean id=\"redisTemplate\" class=\"org.springframework.data.redis.core.RedisTemplate\" \/&gt;\n&lt;bean id=\"myInterface\" class=\"com.example.MyInterfaceImpl\" \/&gt;\n&lt;bean id=\"myThread\" class=\"com.example.MyThread\" \/&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u6837\uff0credistemplate \u548c myinterface \u5c06\u901a\u8fc7\u6784\u9020\u51fd\u6570\u6ce8\u5165 mythread \u7c7b\uff0c\u89e3\u51b3\u6ce8\u5165\u95ee\u9898\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u7ebf\u7a0b\u7c7b\u65e0\u6cd5\u6ce8\u5165Redis\u6216\u63a5\u53e3\uff1f\u5982\u4f55\u4f7f\u7528\u6784\u9020\u6ce8\u5165\u89e3\u51b3\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7ebf\u7a0b\u7c7b\u6ce8\u5165\u95ee\u9898\uff1a\u65e0@autowired\u6ce8\u5165\u65b9\u6cd5 \u4f60\u5728\u7f16\u5199\u7ebf\u7a0b\u7c7b\u65f6\u9047\u5230\u65e0\u6cd5\u6ce8\u5165 \u6216\u63a5\u53e3\u7684\u95ee\u9898\u3002\u8fd9\u662f\u56e0\u4e3a\u7ebf\u7a0b\u65e0\u6cd5\u4f7f\u7528@autowired\u8fdb\u884c\u6ce8\u5165\u3002\u4ee5\u4e0b\u662f\u5982\u4f55\u4f7f\u7528\u6784\u9020\u6ce8\u5165\u65b9\u6cd5\u89e3\u51b3\u6b64\u95ee\u9898\uff1a \u7ebf\u7a0b\u7c7b\uff1a @component public class mythread extends thread { private redistemplate&lt;string, string&gt; redistemplate; private myinterface myinterface; public mythread(redistemplate&lt;string, string&gt; redistemplate, myinterface myinterface) { this.redistemplate = redistemplate; this.myinterface = myinterface; } &#8230; } \u767b\u5f55\u540e\u590d\u5236 \u8c03\u7528\uff1a \/\/ \u6ce8\u5165\u7ebf\u7a0b\u7c7b @autowired private mythread mythread; \/\/ \u542f\u52a8\u7ebf\u7a0b mythread.start(); \u767b\u5f55\u540e\u590d\u5236 \u6ce8\u5165\uff1a \u4f7f\u7528\u4ee5\u4e0b\u914d\u7f6e\u5728\u4e3b\u5e94\u7528\u7a0b\u5e8f\u4e0a\u4e0b\u6587\u4e2d\u914d\u7f6e\u8fd9\u4e09\u4e2a bean\uff1a &lt;bean id=&#8221;redisTemplate&#8221; class=&#8221;org.springframework.data.redis.core.RedisTemplate&#8221; \/&gt; &lt;bean id=&#8221;myInterface&#8221; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-35149","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/35149","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=35149"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/35149\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=35149"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=35149"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=35149"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}