0%

一、机器数和真值

1、机器数

一个数在计算机中的二进制表示形式, 叫做这个数的机器数。机器数是带符号的,在计算机用一个数的最高位存放符号正数为0负数为1

比如,十进制中的数 +3 ,计算机字长为8位,转换成二进制就是00000011。如果是 -3 ,就是 10000011 。

那么,这里的 00000011 和 10000011 就是机器数。

阅读全文 »

工作目录介绍

tomcat的根目录:TOMCAT_HOME=/var/tomcat

部署的文件: /data/app.war

部署的项目首页:index.html

启动tomcat脚本:${TOMCAT_HOME}/bin/startup.sh

停止tomcat脚本:${TOMCAT_HOME}/bin/shutdown.sh

阅读全文 »

tomcat的端口配置主要在${tomcat_home}/conf/server.xml中,如果修改端口号,最好将下面三个位置同时修改。

修改server标记

1
2
<Server port="8005" shutdown="SHUTDOWN">
</Server>

修改web端口

1
2
3
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />

修改AJP端口

1
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

当我们将项目部署到tomcat的时候,通过浏览器方式时必须在URL中携带项目名,也就是要通过Context-Path才能访问到项目,但是有时我们希望自定义Context-Path的值或不使用该值。

为了实现上面的需求,我们需要修改${TOMCAT_HOME}/conf/server.xml文件,在该文件中找到Host标记,并修改为如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<Host name="localhost"  appBase="webapps"
unpackWARs="true" autoDeploy="true">

<!-- 添加该行 -->
<Context path="/" docBase="path your app dir" debug="0" privileged="true" reloadable="false" />

<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-->

<!-- Access log processes all example.
Documentation at: /docs/config/valve.html
Note: The pattern used is equivalent to using pattern="common" -->
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t &quot;%r&quot; %s %b" />

</Host>

<Host>标签中新增了<Context>标记用于自定义Context-path

属性名 属性值
path Context-Path的值,也就是在域名后紧跟的项目名
docBase 项目路径,可以使用相对路径或绝对路径,相对目录的根目录为webapps
debug 设置显示信息量的多少,0:显示最少的信息量,9:显示最多的信息量
privileged 是否允许使用容器中的Servlet
reloadable 是否允许热加载,热加载会消耗服务器性能

maven在idea中使用系统控制台,windows系统的默认编码不是UTF-8,而tomcat的默认控制台编码为UTF-8,从而导致乱码

解决方案

找到tomcat的根目录,conf-> logging.properties

注释java.util.logging.ConsoleHandler.encoding = UTF-8或者将UTF-8修改为GBK

如果我们使用IDEA运行一个Spring Boot的项目,控制台打印的日志是彩色的,但当我们自定义日志配置文件后彩色却消失了。

若我们不是使用的Spring Boot来搭建项目,那我们的控制台打印的日志也是不带颜色。

但是我们想要实现为Spring Boot那中形式该怎么办呢?

阅读全文 »

Logback是由log4j创始人设计的另一个开源日志组件。它包含下面几个模块:

  • logback-core:其它两个模块的基础模块
  • logback-classic:它是log4j的一个改良版本,同时它完整实现了slf4j API使你可以很方便地更换成其它日志系统如log4j或JDK14 Logging
  • logback-access:访问模块与Servlet容器集成提供通过Http来访问日志的功能
阅读全文 »

在编写 hexo 文章时,如果文章中引入了图片资源,我们可以通过以下几种方式进行引入:

  1. 将图片存入CDN
  2. 将图片存放在hexo静态资源文件夹
  3. 将图片放入文章同名目录
阅读全文 »

svn执行clean up命令时报错:Previous operation has not finished; run 'cleanup' if it was interrupted

出现该问题时,即使将本地项目删除都无法解决这个问题。

解决方案有两种:

  • 卸载SVN重新安装
  • 修改SVN数据库
阅读全文 »

修改user/.m2/settings.xml添加mirror

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
 <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository/>
<interactiveMode/>
<offline/>
<pluginGroups/>
<servers/>
<mirrors>
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
  <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
<proxies/>
<profiles/>
<activeProfiles/>
</settings>