{"id":39917,"date":"2023-04-26T04:08:22","date_gmt":"2022-12-04T11:08:45","guid":{"rendered":"https:\/\/www.silicloud.com\/zh\/blog\/%e9%87%87%e7%94%a8grpc%e3%80%81spring-boot%e3%80%81kotlin%e5%92%8cmysql%e5%bc%80%e5%8f%91%e7%9a%84sns%e5%ba%94%e7%94%a8%ef%bc%88%e5%8c%85%e5%90%ab%e9%80%9a%e8%af%9d%e5%92%8c%e8%81%8a%e5%a4%a9%ef%bc%89\/"},"modified":"2024-04-30T01:20:00","modified_gmt":"2024-04-29T17:20:00","slug":"%e9%87%87%e7%94%a8grpc%e3%80%81spring-boot%e3%80%81kotlin%e5%92%8cmysql%e5%bc%80%e5%8f%91%e7%9a%84sns%e5%ba%94%e7%94%a8%ef%bc%88%e5%8c%85%e5%90%ab%e9%80%9a%e8%af%9d%e5%92%8c%e8%81%8a%e5%a4%a9%ef%bc%89","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/zh\/blog\/%e9%87%87%e7%94%a8grpc%e3%80%81spring-boot%e3%80%81kotlin%e5%92%8cmysql%e5%bc%80%e5%8f%91%e7%9a%84sns%e5%ba%94%e7%94%a8%ef%bc%88%e5%8c%85%e5%90%ab%e9%80%9a%e8%af%9d%e5%92%8c%e8%81%8a%e5%a4%a9%ef%bc%89\/","title":{"rendered":"\u91c7\u7528gRPC\u3001Spring Boot\u3001Kotlin\u548cMySQL\u5f00\u53d1\u7684SNS\u5e94\u7528\uff08\u5305\u542b\u901a\u8bdd\u548c\u804a\u5929\uff09\u7684API\u6837\u4f8b"},"content":{"rendered":"<h1>\u8fd9\u4e2a\u5e94\u7528\u7a0b\u5e8f\u7684API\u662f\u4ec0\u4e48\uff1f<\/h1>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u30c1\u30e3\u30c3\u30c8\u3001\u901a\u8a71\u6a5f\u80fd\u304c\u3042\u308bSNS\u30a2\u30d7\u30ea\u306eAPI\u3067\u3059\u3002<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\u30e6\u30fc\u30b6\u30fc\u767b\u9332\u3001\u30d7\u30c3\u30b7\u30e5\u901a\u77e5\u3001\u30d6\u30ed\u30c3\u30af\u30fb\u901a\u5831\u6a5f\u80fd\u306a\u3069\u306esns\u30a2\u30d7\u30ea\u306b\u5fc5\u8981\u306a\u4e00\u901a\u308a\u306eAPI\u3092\u5b9f\u88c5\u3057\u3066\u3044\u307e\u3059\u3002<\/ul>\n<h1>\u7cfb\u7edf\u7684\u6784\u6210<\/h1>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\uff1aSpring Boot<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u8a00\u8a9e\uff1aKotlin<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">API\uff1aProtocol Buffers\u3067\u5b9a\u7fa9\u3001gRPC\u3067\u5b9f\u88c5\u3002<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">DB\uff1aMySQL<\/ul>\n<h1>&#8211; \u4ee3\u7801 (Daima)<\/h1>\n<h2>\u8bc4\u8bba hu\u00e0<br \/>\n)<\/h2>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">gRPC, Protocol Buffers\u304c\u3069\u3093\u306a\u3082\u306e\u304b\u306f\u4ed6\u306b\u6ca2\u5c71\u60c5\u5831\u304c\u3042\u308b\u306e\u3067\u7701\u7565\u3057\u307e\u3059\u3002<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u753b\u50cf\u30d5\u30a1\u30a4\u30eb\u306e\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u306f\u3053\u306e\u30b5\u30f3\u30d7\u30eb\u306b\u542b\u307f\u307e\u305b\u3093\u3002<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">iOS\u30d7\u30c3\u30b7\u30e5\u901a\u77e5\u306e\u7528\u306ep8\u30d5\u30a1\u30a4\u30eb\u3084\u3001\u305d\u306e\u4ed6\u306e\u8a8d\u8a3c\u7528\u306e\u6587\u5b57\u5217\u306f\u7121\u52b9\u306a\u3082\u306e\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/ul>\n<h1>API\u6e05\u5355<\/h1>\n<h2>\u8d26\u53f7<\/h2>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u30e6\u30fc\u30b6\u30fc\u767b\u9332<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u30d7\u30ed\u30d5\u30a3\u30fc\u30eb\u7de8\u96c6<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\u9000\u4f1a<\/ul>\n<h2>\u7528\u6237\u4fe1\u606f:<\/h2>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u30e6\u30fc\u30b6\u30fc\u306e\u30ea\u30b9\u30c8\u53d6\u5f97<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\u6307\u5b9a\u3057\u305fid\u306e\u30e6\u30fc\u30b6\u30fc\u3092\u53d6\u5f97<\/ul>\n<h2>\u6253\u7535\u8bdd<\/h2>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u901a\u8a71\u3092\u958b\u59cb\u3002(\u96fb\u8a71\u3092\u639b\u3051\u308b)<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u901a\u8a71\u3092\u53d7\u3051\u308b\u3002<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u901a\u8a71\u3092\u5207\u308b\u3002<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u901a\u8a71\u304c\u7d99\u7d9a\u3057\u3066\u3044\u308b\u3053\u3068\u3092\u8a18\u9332\u3002<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\u901a\u8a71\u306e\u30b9\u30c6\u30fc\u30bf\u30b9\u53d7\u4fe1(\u958b\u59cb\u3001\u901a\u8a71\u4e2d\u3001\u7d42\u4e86)<\/ul>\n<h2>\u804a\u5929<\/h2>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u30e1\u30c3\u30bb\u30fc\u30b8\u9001\u4fe1<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u30e1\u30c3\u30bb\u30fc\u30b8\u53d7\u4fe1<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\u3059\u3079\u3066\u306e\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u53d6\u5f97<\/ul>\n<h2>\u63a8\u64ad\u901a\u77e5<\/h2>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u30c7\u30d0\u30a4\u30b9\u30c8\u30fc\u30af\u30f3_iOS \/ \u767b\u9332, \u66f4\u65b0<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">ON\/OFF\u66f4\u65b0<\/ul>\n<h2>\u5176\u4ed6<\/h2>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u30e6\u30fc\u30b6\u30fc\u3092\u30d6\u30ed\u30c3\u30af<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\u30e6\u30fc\u30b6\u30fc\u3092\u901a\u5831<\/ul>\n<h1>\u4f7f\u7528Protocol Buffers\u8fdb\u884cAPI\u89c4\u8303\u5b9a\u4e49\u3002<\/h1>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">account.proto<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">block.proto<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">calling.proto<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">chat.proto<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">commons.proto<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">push_notify.proto<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">report.proto<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">user.proto<\/ul>\n<h1>gRPC\u7684\u63a7\u5236\u5668\u7c7b(API)<\/h1>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">AccountGrpcService<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">AccountRegisterGrpcService<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">BlockGrpcService<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">CallingGrpcService<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">ChatGrpcService<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">PushNotifyGrpcService<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">ReportGrpcService<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">UserGrpcService<\/ul>\n<h1>\u5728 build.gradle \u4e2d\uff0c\u4ece proto \u6587\u4ef6\u751f\u6210 API \u7684\u6e90\u7801\u3002<\/h1>\n<pre class=\"post-pre\"><code>group 'com.talking'\r\n\r\n\/\/ gRPC\u306e\u30b3\u30fc\u30c9\u751f\u6210\u30b3\u30de\u30f3\u30c9: .\/gradlew generateProto\r\n\r\n\/\/ \u30c9\u30ad\u30e5\u30e1\u30f3\u30c8: gRPC\u306e\u5b9f\u88c5\r\n\/\/ https:\/\/github.com\/LogNet\/grpc-spring-boot-starter\r\n\r\nbuildscript {\r\n    ext.kotlin_version = '1.3.61' \/\/ Required for Kotlin integration\r\n    ext.spring_boot_version = '2.2.0.RELEASE'\r\n    repositories {\r\n        mavenCentral()\r\n    }\r\n    dependencies {\r\n        classpath \"org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version\" \/\/ Required for Kotlin integration\r\n        classpath \"org.jetbrains.kotlin:kotlin-allopen:$kotlin_version\" \/\/ See https:\/\/kotlinlang.org\/docs\/reference\/compiler-plugins.html#spring-support\r\n        classpath \"org.springframework.boot:spring-boot-gradle-plugin:$spring_boot_version\"\r\n\r\n        classpath \"com.google.protobuf:protobuf-gradle-plugin:0.8.5\"\r\n    }\r\n}\r\n\r\napply plugin: 'kotlin' \/\/ Required for Kotlin integration\r\napply plugin: \"kotlin-spring\" \/\/ https:\/\/kotlinlang.org\/docs\/reference\/compiler-plugins.html#spring-support\r\napply plugin: 'org.springframework.boot'\r\napply plugin: 'com.google.protobuf'\r\n\r\ndef grpcVersion = '1.25.0'\r\n\r\nrepositories {\r\n    mavenCentral()\r\n}\r\n\r\nsourceSets {\r\n    main.kotlin.srcDirs += 'src\/main\/kotlin'\r\n    main.java.srcDirs += 'src\/main\/java'\r\n    main.java.srcDirs += 'src\/main\/generated-proto'\r\n}\r\n\r\ndependencies {\r\n    compile(\"org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version\")\r\n    compile(\"org.jetbrains.kotlin:kotlin-reflect:$kotlin_version\")\r\n    \/\/ testCompile('org.springframework.boot:spring-boot-starter-test')\r\n\r\n    \/\/ for web\r\n    compile(\"org.springframework.boot:spring-boot-starter-web:$spring_boot_version\")\r\n    compile(\"com.fasterxml.jackson.module:jackson-module-kotlin:2.9.8\")\r\n\r\n    \/\/ for db\r\n    compile(\"org.springframework.boot:spring-boot-starter-data-jpa:$spring_boot_version\")\r\n    runtime(\"mysql:mysql-connector-java:8.0.15\")\r\n\r\n    compile(\"org.springframework.boot:spring-boot-starter-security:$spring_boot_version\")\r\n\r\n    \/\/ grpc\r\n    compile(\"io.github.lognet:grpc-spring-boot-starter:3.5.0\")\r\n    compile \"io.grpc:grpc-api:${grpcVersion}\"\r\n    compile \"io.netty:netty-codec-http2:4.1.42.Final\"\r\n    compile \"io.grpc:grpc-core:${grpcVersion}\"\r\n    compile \"io.grpc:grpc-protobuf:${grpcVersion}\"\r\n    compile \"io.grpc:grpc-stub:${grpcVersion}\"\r\n\r\n    \/\/ cache\r\n    compile(group: 'com.github.ben-manes.caffeine', name: 'caffeine', version: '2.8.1')\r\n    \/\/ iOS\u30d7\u30c3\u30b7\u30e5\u901a\u77e5\r\n    compile(group: 'com.eatthepath', name: 'pushy', version: '0.13.11')\r\n\r\n}\r\n\r\ncompileKotlin {\r\n    kotlinOptions.jvmTarget = \"1.8\"\r\n}\r\ncompileTestKotlin {\r\n    kotlinOptions.jvmTarget = \"1.8\"\r\n}\r\n\r\nprotobuf {\r\n    protoc {\r\n        artifact = \"com.google.protobuf:protoc:3.5.0\"\r\n    }\r\n\r\n    plugins {\r\n        grpc {\r\n            artifact = \"io.grpc:protoc-gen-grpc-java:${grpcVersion}\"\r\n        }\r\n    }\r\n\r\n    generateProtoTasks {\r\n        all().each { task -&gt;\r\n            task.builtins {\r\n                java {\r\n                    outputSubDir = 'generated-proto'\r\n                }\r\n            }\r\n            task.plugins {\r\n                grpc {\r\n                    outputSubDir = 'generated-proto'\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    generatedFilesBaseDir = \"$projectDir\/src\/\"\r\n}\r\n<\/code><\/pre>\n<h1>\u622a\u6b62\u65e5\u671f<\/h1>\n<h3>\u684c\u5b50<\/h3>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u30e6\u30fc\u30b6\u30fc<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u30d7\u30ed\u30d5\u30a3\u30fc\u30eb\u753b\u50cf<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u30c1\u30e3\u30c3\u30c8<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u901a\u8a71\u5c65\u6b74<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u901a\u5831<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u30d6\u30ed\u30c3\u30af<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\u30d7\u30c3\u30b7\u30e5\u901a\u77e5\u30c7\u30d0\u30a4\u30b9\u30c8\u30fc\u30af\u30f3_iOS<\/ul>\n<h1>\u52aa\u529b\u4e86\u4e00\u4e0b<\/h1>\n<h2>\u5c06\u4ec5\u5141\u8bb8\u767b\u5f55\u7528\u6237\u4f7f\u7528\u7684API\u8ba4\u8bc1\u8fc7\u7a0b\u8fdb\u884c\u5171\u901a\u5316\u5904\u7406\u3002<\/h2>\n<p>\u5728AuthInterceptor\u4e2d\u4f7f\u7528request\u5934\u90e8\u4e2d\u7684token\u548cuserId\u8fdb\u884c\u8eab\u4efd\u9a8c\u8bc1\u3002<\/p>\n<pre class=\"post-pre\"><code>@Component\r\nclass AuthInterceptor : ServerInterceptor {\r\n\r\n    @Autowired\r\n    private lateinit var userService: UserService\r\n\r\n    \/\/ \u53c2\u8003\u30bd\u30fc\u30b9:\r\n    \/\/ https:\/\/github.com\/saturnism\/grpc-by-example-java\/blob\/master\/metadata-context-example\/src\/main\/java\/com\/example\/grpc\/server\/JwtServerInterceptor.java\r\n\r\n    override fun &lt;ReqT : Any?, RespT : Any?&gt; interceptCall(\r\n        call: ServerCall&lt;ReqT, RespT&gt;,\r\n        headers: Metadata,\r\n        next: ServerCallHandler&lt;ReqT, RespT&gt;\r\n    ): ServerCall.Listener&lt;ReqT&gt; {\r\n\r\n        val userId = headers.get(GrpcConstant.USER_ID_METADATA_KEY)?.toLong() ?:\r\n                throw StatusRuntimeException(Status.UNAUTHENTICATED, headers)\r\n\r\n        val apiToken = headers.get(GrpcConstant.API_TOKEN_METADATA_KEY) ?:\r\n                throw StatusRuntimeException(Status.UNAUTHENTICATED, headers)\r\n\r\n        val user = userService.findByIdAndToken(userId, apiToken) ?:\r\n            throw StatusRuntimeException(Status.UNAUTHENTICATED, headers)\r\n\r\n        val ctx = Context.current().withValue(GrpcConstant.AUTH_USER_CONTEXT_KEY, user)\r\n        return Contexts.interceptCall(ctx, call, headers, next)\r\n    }\r\n}\r\n<\/code><\/pre>\n<p>\u5728\u60f3\u8981\u4f7f\u7528\u8ba4\u8bc1\u5904\u7406\u7684API\u7c7b\u4e2d\u8bbe\u7f6eAuthInterceptor\u3002<br \/>\nhttps:\/\/github.com\/yusuke-imagawa\/talking-sns-api-sample\/blob\/master\/src\/main\/kotlin\/com\/talking\/api\/grpc\/AccountGrpcService.kt<\/p>\n<pre class=\"post-pre\"><code>@GRpcService(interceptors = [AuthInterceptor::class])\r\nclass AccountGrpcService: AccountServiceGrpc.AccountServiceImplBase() {\r\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u8fd9\u4e2a\u5e94\u7528\u7a0b\u5e8f\u7684API\u662f\u4ec0\u4e48\uff1f \u30c1\u30e3\u30c3\u30c8\u3001\u901a\u8a71\u6a5f\u80fd\u304c\u3042\u308bSNS\u30a2\u30d7\u30ea\u306eAPI\u3067\u3059\u3002 &nbsp; \u30e6\u30fc\u30b6\u30fc\u767b\u9332\u3001 [&hellip;]<\/p>\n","protected":false},"author":10,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-39917","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u91c7\u7528gRPC\u3001Spring Boot\u3001Kotlin\u548cMySQL\u5f00\u53d1\u7684SNS\u5e94\u7528\uff08\u5305\u542b\u901a\u8bdd\u548c\u804a\u5929\uff09\u7684API\u6837\u4f8b - Blog - Silicon Cloud<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silicloud.com\/zh\/blog\/\u91c7\u7528grpc\u3001spring-boot\u3001kotlin\u548cmysql\u5f00\u53d1\u7684sns\u5e94\u7528\uff08\u5305\u542b\u901a\u8bdd\u548c\u804a\u5929\uff09\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u91c7\u7528gRPC\u3001Spring Boot\u3001Kotlin\u548cMySQL\u5f00\u53d1\u7684SNS\u5e94\u7528\uff08\u5305\u542b\u901a\u8bdd\u548c\u804a\u5929\uff09\u7684API\u6837\u4f8b\" \/>\n<meta property=\"og:description\" content=\"\u8fd9\u4e2a\u5e94\u7528\u7a0b\u5e8f\u7684API\u662f\u4ec0\u4e48\uff1f \u30c1\u30e3\u30c3\u30c8\u3001\u901a\u8a71\u6a5f\u80fd\u304c\u3042\u308bSNS\u30a2\u30d7\u30ea\u306eAPI\u3067\u3059\u3002 &nbsp; \u30e6\u30fc\u30b6\u30fc\u767b\u9332\u3001 [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/zh\/blog\/\u91c7\u7528grpc\u3001spring-boot\u3001kotlin\u548cmysql\u5f00\u53d1\u7684sns\u5e94\u7528\uff08\u5305\u542b\u901a\u8bdd\u548c\u804a\u5929\uff09\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2022-12-04T11:08:45+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-29T17:20:00+00:00\" \/>\n<meta name=\"author\" content=\"\u5b87, \u534e\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u5b87, \u534e\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e9%87%87%e7%94%a8grpc%e3%80%81spring-boot%e3%80%81kotlin%e5%92%8cmysql%e5%bc%80%e5%8f%91%e7%9a%84sns%e5%ba%94%e7%94%a8%ef%bc%88%e5%8c%85%e5%90%ab%e9%80%9a%e8%af%9d%e5%92%8c%e8%81%8a%e5%a4%a9%ef%bc%89\/\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e9%87%87%e7%94%a8grpc%e3%80%81spring-boot%e3%80%81kotlin%e5%92%8cmysql%e5%bc%80%e5%8f%91%e7%9a%84sns%e5%ba%94%e7%94%a8%ef%bc%88%e5%8c%85%e5%90%ab%e9%80%9a%e8%af%9d%e5%92%8c%e8%81%8a%e5%a4%a9%ef%bc%89\/\",\"name\":\"\u91c7\u7528gRPC\u3001Spring Boot\u3001Kotlin\u548cMySQL\u5f00\u53d1\u7684SNS\u5e94\u7528\uff08\u5305\u542b\u901a\u8bdd\u548c\u804a\u5929\uff09\u7684API\u6837\u4f8b - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\"},\"datePublished\":\"2022-12-04T11:08:45+00:00\",\"dateModified\":\"2024-04-29T17:20:00+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/513018e4e121d3add1b7c5de8be21458\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e9%87%87%e7%94%a8grpc%e3%80%81spring-boot%e3%80%81kotlin%e5%92%8cmysql%e5%bc%80%e5%8f%91%e7%9a%84sns%e5%ba%94%e7%94%a8%ef%bc%88%e5%8c%85%e5%90%ab%e9%80%9a%e8%af%9d%e5%92%8c%e8%81%8a%e5%a4%a9%ef%bc%89\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/zh\/blog\/%e9%87%87%e7%94%a8grpc%e3%80%81spring-boot%e3%80%81kotlin%e5%92%8cmysql%e5%bc%80%e5%8f%91%e7%9a%84sns%e5%ba%94%e7%94%a8%ef%bc%88%e5%8c%85%e5%90%ab%e9%80%9a%e8%af%9d%e5%92%8c%e8%81%8a%e5%a4%a9%ef%bc%89\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e9%87%87%e7%94%a8grpc%e3%80%81spring-boot%e3%80%81kotlin%e5%92%8cmysql%e5%bc%80%e5%8f%91%e7%9a%84sns%e5%ba%94%e7%94%a8%ef%bc%88%e5%8c%85%e5%90%ab%e9%80%9a%e8%af%9d%e5%92%8c%e8%81%8a%e5%a4%a9%ef%bc%89\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/zh\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u91c7\u7528gRPC\u3001Spring Boot\u3001Kotlin\u548cMySQL\u5f00\u53d1\u7684SNS\u5e94\u7528\uff08\u5305\u542b\u901a\u8bdd\u548c\u804a\u5929\uff09\u7684API\u6837\u4f8b\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/\",\"name\":\"Blog - Silicon Cloud\",\"description\":\"\",\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/513018e4e121d3add1b7c5de8be21458\",\"name\":\"\u5b87, \u534e\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/63cd45cbc05a35fc4ff7637a163c83c4962ef58d27472726c3a3e0c9c5194f0f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/63cd45cbc05a35fc4ff7637a163c83c4962ef58d27472726c3a3e0c9c5194f0f?s=96&d=mm&r=g\",\"caption\":\"\u5b87, \u534e\"},\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/author\/yuhua\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e9%87%87%e7%94%a8grpc%e3%80%81spring-boot%e3%80%81kotlin%e5%92%8cmysql%e5%bc%80%e5%8f%91%e7%9a%84sns%e5%ba%94%e7%94%a8%ef%bc%88%e5%8c%85%e5%90%ab%e9%80%9a%e8%af%9d%e5%92%8c%e8%81%8a%e5%a4%a9%ef%bc%89\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"\u91c7\u7528gRPC\u3001Spring Boot\u3001Kotlin\u548cMySQL\u5f00\u53d1\u7684SNS\u5e94\u7528\uff08\u5305\u542b\u901a\u8bdd\u548c\u804a\u5929\uff09\u7684API\u6837\u4f8b - Blog - Silicon Cloud","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.silicloud.com\/zh\/blog\/\u91c7\u7528grpc\u3001spring-boot\u3001kotlin\u548cmysql\u5f00\u53d1\u7684sns\u5e94\u7528\uff08\u5305\u542b\u901a\u8bdd\u548c\u804a\u5929\uff09\/","og_locale":"zh_CN","og_type":"article","og_title":"\u91c7\u7528gRPC\u3001Spring Boot\u3001Kotlin\u548cMySQL\u5f00\u53d1\u7684SNS\u5e94\u7528\uff08\u5305\u542b\u901a\u8bdd\u548c\u804a\u5929\uff09\u7684API\u6837\u4f8b","og_description":"\u8fd9\u4e2a\u5e94\u7528\u7a0b\u5e8f\u7684API\u662f\u4ec0\u4e48\uff1f \u30c1\u30e3\u30c3\u30c8\u3001\u901a\u8a71\u6a5f\u80fd\u304c\u3042\u308bSNS\u30a2\u30d7\u30ea\u306eAPI\u3067\u3059\u3002 &nbsp; \u30e6\u30fc\u30b6\u30fc\u767b\u9332\u3001 [&hellip;]","og_url":"https:\/\/www.silicloud.com\/zh\/blog\/\u91c7\u7528grpc\u3001spring-boot\u3001kotlin\u548cmysql\u5f00\u53d1\u7684sns\u5e94\u7528\uff08\u5305\u542b\u901a\u8bdd\u548c\u804a\u5929\uff09\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2022-12-04T11:08:45+00:00","article_modified_time":"2024-04-29T17:20:00+00:00","author":"\u5b87, \u534e","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"\u5b87, \u534e","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e9%87%87%e7%94%a8grpc%e3%80%81spring-boot%e3%80%81kotlin%e5%92%8cmysql%e5%bc%80%e5%8f%91%e7%9a%84sns%e5%ba%94%e7%94%a8%ef%bc%88%e5%8c%85%e5%90%ab%e9%80%9a%e8%af%9d%e5%92%8c%e8%81%8a%e5%a4%a9%ef%bc%89\/","url":"https:\/\/www.silicloud.com\/zh\/blog\/%e9%87%87%e7%94%a8grpc%e3%80%81spring-boot%e3%80%81kotlin%e5%92%8cmysql%e5%bc%80%e5%8f%91%e7%9a%84sns%e5%ba%94%e7%94%a8%ef%bc%88%e5%8c%85%e5%90%ab%e9%80%9a%e8%af%9d%e5%92%8c%e8%81%8a%e5%a4%a9%ef%bc%89\/","name":"\u91c7\u7528gRPC\u3001Spring Boot\u3001Kotlin\u548cMySQL\u5f00\u53d1\u7684SNS\u5e94\u7528\uff08\u5305\u542b\u901a\u8bdd\u548c\u804a\u5929\uff09\u7684API\u6837\u4f8b - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website"},"datePublished":"2022-12-04T11:08:45+00:00","dateModified":"2024-04-29T17:20:00+00:00","author":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/513018e4e121d3add1b7c5de8be21458"},"breadcrumb":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e9%87%87%e7%94%a8grpc%e3%80%81spring-boot%e3%80%81kotlin%e5%92%8cmysql%e5%bc%80%e5%8f%91%e7%9a%84sns%e5%ba%94%e7%94%a8%ef%bc%88%e5%8c%85%e5%90%ab%e9%80%9a%e8%af%9d%e5%92%8c%e8%81%8a%e5%a4%a9%ef%bc%89\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/zh\/blog\/%e9%87%87%e7%94%a8grpc%e3%80%81spring-boot%e3%80%81kotlin%e5%92%8cmysql%e5%bc%80%e5%8f%91%e7%9a%84sns%e5%ba%94%e7%94%a8%ef%bc%88%e5%8c%85%e5%90%ab%e9%80%9a%e8%af%9d%e5%92%8c%e8%81%8a%e5%a4%a9%ef%bc%89\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e9%87%87%e7%94%a8grpc%e3%80%81spring-boot%e3%80%81kotlin%e5%92%8cmysql%e5%bc%80%e5%8f%91%e7%9a%84sns%e5%ba%94%e7%94%a8%ef%bc%88%e5%8c%85%e5%90%ab%e9%80%9a%e8%af%9d%e5%92%8c%e8%81%8a%e5%a4%a9%ef%bc%89\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/zh\/blog\/"},{"@type":"ListItem","position":2,"name":"\u91c7\u7528gRPC\u3001Spring Boot\u3001Kotlin\u548cMySQL\u5f00\u53d1\u7684SNS\u5e94\u7528\uff08\u5305\u542b\u901a\u8bdd\u548c\u804a\u5929\uff09\u7684API\u6837\u4f8b"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website","url":"https:\/\/www.silicloud.com\/zh\/blog\/","name":"Blog - Silicon Cloud","description":"","inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/513018e4e121d3add1b7c5de8be21458","name":"\u5b87, \u534e","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/63cd45cbc05a35fc4ff7637a163c83c4962ef58d27472726c3a3e0c9c5194f0f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/63cd45cbc05a35fc4ff7637a163c83c4962ef58d27472726c3a3e0c9c5194f0f?s=96&d=mm&r=g","caption":"\u5b87, \u534e"},"url":"https:\/\/www.silicloud.com\/zh\/blog\/author\/yuhua\/"},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e9%87%87%e7%94%a8grpc%e3%80%81spring-boot%e3%80%81kotlin%e5%92%8cmysql%e5%bc%80%e5%8f%91%e7%9a%84sns%e5%ba%94%e7%94%a8%ef%bc%88%e5%8c%85%e5%90%ab%e9%80%9a%e8%af%9d%e5%92%8c%e8%81%8a%e5%a4%a9%ef%bc%89\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/39917","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/comments?post=39917"}],"version-history":[{"count":2,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/39917\/revisions"}],"predecessor-version":[{"id":88813,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/39917\/revisions\/88813"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/media?parent=39917"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/categories?post=39917"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/tags?post=39917"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}