↓ Skip to main content
  1. Tags/

Java

2018

java-grpc 踩坑记录

·1789 words·4 mins
最近的项目需要java和python之间的进程通信,想到了之前使用过的 grpc。 参考官方quickstart JDK: version 7 or higher 看起来只依赖jdk,美滋滋 然后按照文档执行 ./gradlew installDist 报错: 1Task :grpc-compiler:compileJava_pluginExecutableJava_pluginCpp FAILED 2 3FAILURE: Build failed with an exception. 4 5* What went wrong: 6Execution failed for task ':grpc-compiler:compileJava_pluginExecutableJava_pluginCpp'. 7> No tool chain is available to build for platform 'x86_64': 8 - Tool chain 'visualCpp' (Visual Studio): Visual Studio is not available on this operating system. 9 - Tool chain 'gcc' (GNU GCC): Could not determine GCC metadata: could not find vendor in output of /usr/local/gcc-4.9.4/bin/gcc. 10 - Tool chain 'clang' (Clang): Could not find C compiler 'clang' in system path. 11 12* Try: 13Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. 14 15* Get more help at https://help.gradle.org 16 17BUILD FAILED in 3m 47s 18 19~ 看起来是 gcc 或者 clang 的问题… 先装个 clang 再说,可能 clang 太常用了,所以文档没有提到,这下一定可以了。

spring 学习笔记

·496 words·1 min
迫于生计,又要从零开始学习spring. 在这篇文章之前,对java的基础是2015年写过一个java大作业,对spring是一无所知。 为了学习spring,我按顺序做了以下事情:

spring 依赖注入

·621 words·2 mins
真是个不明觉厉的术语…其实是个特别简单的概念orz 用白话讲,如果一个class A中用到了class B的实例,那么class B的实例就是class A的依赖,如果不是在class A中定义class B的实例,而是通过某个接口,将class B的实例传入class A,就叫依赖注入。

learn java in 21 minutes for C++ Programmers

·761 words·2 mins
先放资料: Learning a New Programming Language: Java for C++ Programmers java package # 先说几条重要的人话: 一个 java 文件第一行可以声明该文件所属于的 package,package 的名字必须与整个工作目录的路径名相同。 同一个 package 下的 class 默认有互相访问的权限。 访问属性设置为 public 的 class,如果该 class 所在的 file 声明了 package,那么可以被其他 package 下的 class 访问到。 .java 的文件名必须与文件中设置为 public 的 class 名保持一致(如果没有 public 的类,那么名称任意)。 Every class is part of some package. All classes in a file are part of the same package. You can specify the package using a package declaration (package name;) as the first (non-comment) line in the file. Multiple files can specify the same package name. If no package is specified, the classes in the file go into a special unnamed package (the same unnamed package for all files). If package name is specified, the file must be in a subdirectory called name (i.e., the directory name must match the package name). You can access public classes in another (named) package using package-name.class-name. You can access the public fields and methods of such classes using package-name.class-name.field-or-method-name. You can avoid having to include the package-name using import package-name.*; or import package-name.class-name; at the beginning of the file (after the package declaration). The former imports all of the classes in the package, and the second imports just the named class. You must still use class-name to access the classes in the packages, and class-name.field-or-method-name to access the fields and methods of the class; the only thing you can leave off is the package name. 下面是一些例子:

2016