[mysql] socket=/var/lib/mysql/mysql.sock # set mysql client default chararter default-character-set=utf8 # [mysqld] socket=/var/lib/mysql/mysql.sock bind-address=0.0.0.0 # set mysql server port port = 3306 #默认是3306,防止这种情况发生,可以避免使用3306mysql默认端口 # set mysql install base dir basedir=/usr/local/mysql # set the data store dir datadir=/usr/local/mysql/data # set the number of allow max connnection max_connections=200000 # set server charactre default encoding character-set-server=utf8 # the storage engine default-storage-engine=INNODB # lower_case_table_names=1 max_allowed_packet=16M explicit_defaults_for_timestamp=true
vim /usr/local/apache-tomcat-8.5.40/conf/context.xml
1 2 3 4 5 6 7 8 9 10 11 12
<Context caseSensitive="false">
<!-- Default set of monitored resources. If one of these changes, the --> <!-- web application will be reloaded. --> <WatchedResource>WEB-INF/web.xml</WatchedResource> <WatchedResource>${catalina.base}/conf/web.xml</WatchedResource>
<!-- Uncomment this to disable session persistence across Tomcat restarts --> <!-- <Manager pathname="" /> --> </Context>
重启
1 2
systemctl status tomcat8 systemctl restart tomcat8
上述例子定义保留属性为 “foo”, “bar” ,定义保留属性位置为2,即在2这个位置上不可以定义属性,如: string name=2; 是不允许的,编译器在编译 proto 文件的时候如果发现,2这个位置上有属性被定义则会报错。
数据类型
.proto文件的值类型和 java 的值类型的对照表:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
.proto Type Java Type doubledouble floatfloat int32 int int64 long uint32 int uint64 long sint32 int sint64 long fixed32 int fixed64 long sfixed32 int sfixed64 long bool boolean string String bytes ByteString
默认值
当 proto 消息被解析成具体的语言的时候,如果消息编码没包含特定的元素,则消息对象中的属性会被设置默认值,这些默认值具体如下:
string 类型,默认值是空字符串,注意不是null
bytes 类型,默认值是空bytes
bool 类型,默认值是false
数字 类型,默认值是0
枚举 类型,默认值是第一个枚举值,即0
repeated 修饰的属性,默认值是空(在相对应的编程语言中通常是一个空的list).
枚举
proto 允许你在定义的消息类型的时候定义枚举类型,如下例,在消息类型中定义并使用枚举类型:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
message SearchRequest { string query = 1; int32 page_number = 2; int32 result_per_page = 3; enum Corpus { UNIVERSAL = 0; WEB = 1; IMAGES = 2; LOCAL = 3; NEWS = 4; PRODUCTS = 5; VIDEO = 6; } Corpus corpus = 4; }
如上例中所示, Corpus 枚举类型的第一个枚举值是0,每一个枚举值定义都会与一个常量映射,而这些常量的第一个常量值必须为0,原因如下: