凭海临风的IT江湖

  • 首页

  • 关于

  • 标签

  • 分类

  • 归档

  • 站点地图

  • 公益 404

  • 时间轴

  • 搜索

maven3-jdk1.7-problem-fixed

发表于 2016-02-13 | 更新于 2022-08-18 | 分类于 ci
本文字数: 2.8k | 阅读时长 ≈ 3 分钟

maven3下jdk1.7编译错误解决

环境

1
2
3
4
5
6
7
8

Apache Maven 3.3.3 (7994120775791599e205a5524ec3e0dfe41d4a06; 2015-04-22T19:57:3
7+08:00)
Maven home: d:\tools\apache-maven-3.3.3
Java version: 1.7.0_45, vendor: Oracle Corporation
Java home: c:\Program Files\Java\jdk1.7.0_45\jre
Default locale: zh_CN, platform encoding: GBK
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"

使用maven命令行创建java项目

1
mvn archetype:generate -DgroupId=org.linfeng -DartifactId=mavendemo -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
  • 创建成功
1
2
$ cd mavendemo && ls
pom.xml src
  • pom.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.linfeng</groupId>
<artifactId>mavendemo</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>mavendemo</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
  • 执行maven命令

mvn test

  • 错误信息
1
2
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project mavendemo: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?

解决方案

  • 修改settings.xml,添加jdk1.7相关内容
1
2
3
4
5
6
7
8
9
10
11
12
<profile>
<id>jdk-1.7</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>1.7</jdk>
</activation>
<properties>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<maven.compiler.compilerVersion>1.7</maven.compiler.compilerVersion>
</properties>
</profile>

缺点:修改所有项目的jre环境

  • 修改当前项目的pom.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>

重新执行mvn build 成功!

问题分析

Maven官方文档有如下描述:

编译器插件用来编译项目的源文件.从3.0版本开始, 用来编译Java源文件的默认编译器是javax.tools.JavaCompiler (如果你是用的是java 1.6) . 如果你想强制性的让插件使用javac,你必须配置插件选项 forceJavacCompilerUse.
同时需要注意的是目前source选项和target 选项的默认设置都是1.5, 与运行Maven时的JDK版本无关.如果你想要改变这些默认设置, 可以参考 Setting the -source and -target of the Java Compiler中的描述来设置 source 和target 选项.

#参考资料

  • http://stackoverflow.com/questions/15220392/maven-package-compilation-error
  • http://www.cnblogs.com/leo100w/p/4017647.html

how make cygwin multi-color

发表于 2015-08-12 | 更新于 2022-08-18 | 分类于 linux
本文字数: 1.5k | 阅读时长 ≈ 1 分钟

打开.bashrc

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# Default to human readable figures
# alias df='df -h'
# alias du='du -h'
#
# Misc
# alias less='less -r' # raw control characters
# alias whence='type -a' # where, of a sort
# alias grep='grep --color' # show differences in colour
# alias egrep='egrep --color=auto' # show differences in colour
# alias fgrep='fgrep --color=auto' # show differences in colour
#
# Some shortcuts for different directory listings
# alias ls='ls -hF --color=tty' # classify files in colour
# alias dir='ls --color=auto --format=vertical'
# alias vdir='ls --color=auto --format=long'
# alias ll='ls -l' # long list
# alias la='ls -A' # all but . and ..
# alias l='ls -CF' #

而我们要做的只是去掉#,启动即可:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# Default to human readable figures
alias df='df -h'
alias du='du -h'
#
# Misc
alias less='less -r' # raw control characters
alias whence='type -a' # where, of a sort
alias grep='grep --color' # show differences in colour
alias egrep='egrep --color=auto' # show differences in colour
alias fgrep='fgrep --color=auto' # show differences in colour
#
# Some shortcuts for different directory listings
alias ls='ls -hF --color=tty' # classify files in colour
alias dir='ls --color=auto --format=vertical'
alias vdir='ls --color=auto --format=long'
alias ll='ls -l' # long list
alias la='ls -A' # all but . and ..
alias l='ls -CF' #

然后保存一下,再重启cygwin(或者直接用:source ~/.bashrc)

how to build a private docker registry

发表于 2015-07-21 | 更新于 2022-08-18 | 分类于 docker
本文字数: 1.7k | 阅读时长 ≈ 2 分钟

如何搭建docker私服

环境准备

软件包:

  • centos6.5_x86_64

  • docker-engine-1.7.0-1.el6.x86_64.rpm

docker环境搭建,请参照官方说明,本文采用的是官方的rpm包

何谓私服

官方的image镜像站位dockerhub,因为伟大的墙的缘故,所以下载镜像是很痛苦的一件事。当然你可以采用其他科学上网或者镜像加速的方法来获取image。
docker官方也提供了一个私服镜像,大家可以通过docker search registry来查找该镜像。

1
2
3
4
5
NAME                                     DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
registry Containerized docker registry 320 [OK]
atcol/docker-registry-ui A web UI for easy private/local Docker Reg... 55 [OK]
konradkleine/docker-registry-frontend Browse and modify your Docker registry in ... 40 [OK]
samalba/docker-registry 35

下载官方registry镜像

  • 下载镜像

使用命令docker pull registry执行下载镜像。

  • 查看镜像

下载完毕后,通过docker images 查看该镜像。

  • 给镜像打标签

执行这个命令

1
docker tag registry:latest localhost:5000/registry:latest

启动镜像

1
docker run -d -e SETTINGS_FLAVOR=dev -e STORAGE_PATH=/tmp/registry -v /opt/data/registry:/tmp/registry  -p 5000:5000 registry

这里有几个参数说明下:

  • 1.-e STORAGE_PATH=/tmp/registry :强制使用存储路径
  • 2.-v /opt/data/registry:/tmp/registry :绑定本地镜像存储路径
  • 3.-p 5000:5000:映射容器5000端口到本地5000端口

查看镜像状态

docker ps

查看私服状态

curl http://localhost:5000

显示如下信息,证明registry启动成功:

"\"docker-registry server\""

推送本地镜像库到registry私服

1. 第一步 给本地镜像 打tag

例如给官方的nginx镜像打tag,执行下面的命令行

docker pull nginx

docker tag nginx:latest localhost:5000/nginx:latest

查看镜像库,发现localhost:5000/nginx的镜像已经有了。

2. 第二步 推送tag到registry私服

docker push localhost:5000/nginx:latest

3. 第三步 查看私服镜像列表

curl http://localhost:5000/V1/search

看到类似这样的信息

1
2

{"num_results": 5, "query": "", "results": [{"description": null, "name": "correl/erlang"}, {"description": null, "name": "linfeng/cmd"}, {"description": null, "name": "library/my_nodejs_image"}, {"description": null, "name": "library/centos"}, {"description": "", "name": "library/nginx"}]}

拉取私服镜像

1
docker pull 192.168.20.85:5000/library/centos:7

结论

这只是演示如何搭建一个简单的registry私服。因为只有通过命令行方式才能查看私服信息,所以不是很便于操作。下面的博文将演示如何给registry添加web界面。

how to build a private docker registry

发表于 2015-07-21 | 更新于 2022-08-18 | 分类于 docker
本文字数: 2k | 阅读时长 ≈ 2 分钟

如何搭建docker私服

##环境准备

软件包:

  • centos6.5_x86_64

  • docker-engine-1.7.0-1.el6.x86_64.rpm

docker环境搭建,请参照官方说明,本文采用的是官方的rpm包

##何谓私服

官方的image镜像站位dockerhub,因为伟大的墙的缘故,所以下载镜像是很痛苦的一件事。当然你可以采用其他科学上网或者镜像加速的方法来获取image。
docker官方也提供了一个私服镜像,大家可以通过docker search registry来查找该镜像。

1
2
3
4
5
NAME                                     DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
registry Containerized docker registry 320 [OK]
atcol/docker-registry-ui A web UI for easy private/local Docker Reg... 55 [OK]
konradkleine/docker-registry-frontend Browse and modify your Docker registry in ... 40 [OK]
samalba/docker-registry 35

##下载官方registry镜像

  • 下载镜像

使用命令docker pull registry执行下载镜像。

  • 查看镜像

下载完毕后,通过docker images 查看该镜像。

  • 给镜像打标签

执行这个命令
docker tag registry:latest localhost:5000/registry:latest

##启动镜像

docker run -d -e SETTINGS_FLAVOR=dev -e STORAGE_PATH=/tmp/registry -v /opt/data/registry:/tmp/registry -p 5000:5000 registry

这里有几个参数说明下:

  • 1.-e STORAGE_PATH=/tmp/registry :强制使用存储路径
  • 2.-v /opt/data/registry:/tmp/registry :绑定本地镜像存储路径
  • 3.-p 5000:5000:映射容器5000端口到本地5000端口

##查看镜像状态

docker ps

##查看私服状态

curl http://localhost:5000

显示如下信息,证明registry启动成功:

"\"docker-registry server\""

##推送本地镜像库到registry私服

###1. 第一步 给本地镜像 打tag
例如给官方的nginx镜像打tag,执行下面的命令行
docker pull nginx
docker tag nginx:latest localhost:5000/nginx:latest
查看镜像库,发现localhost:5000/nginx的镜像已经有了。

###2. 第二步 推送tag到registry私服

docker push localhost:5000/nginx:latest

###3. 第三步 查看私服镜像列表

curl http://localhost:5000/V1/search

看到类似这样的信息

1
2

{"num_results": 5, "query": "", "results": [{"description": null, "name": "correl/erlang"}, {"description": null, "name": "linfeng/cmd"}, {"description": null, "name": "library/my_nodejs_image"}, {"description": null, "name": "library/centos"}, {"description": "", "name": "library/nginx"}]}

##拉取私服镜像

docker pull 192.168.20.85:5000/library/centos:7

##结论

这只是演示如何搭建一个简单的registry私服。因为只有通过命令行方式才能查看私服信息,所以不是很便于操作。下面的博文将演示如何给registry添加web界面。

how git version rollback

发表于 2015-05-16 | 更新于 2022-08-18 | 分类于 git
本文字数: 1.7k | 阅读时长 ≈ 2 分钟

Git如何进行远程版本回退……

引言

一切都要从一个蛋疼的需求开始,老板说,能给远程仓库的版本回退吗?我说为毛?他说我就是试试看git好使不,我……

咋搞

  • 背景

gitcafe 国内知名的源码托管平台

  • 分析
1
2
3
4
5
6
7
8
9
10
11
12
13
14

1、git checkout the_branch

2、git pull

3、git branch the_branch_backup //备份一下这个分支当前的情况

4、git reset --hard the_commit_id //把the_branch本地回滚到the_commit_id

5、git push origin :the_branch //删除远程 the_branch

6、git push origin the_branch //用回滚后的本地分支重新建立远程分支

7、git push origin :the_branch_backup //如果前面都成功了,删除这个备份分支
  • 删除远程分支

首先,任何一个git源码托管平台都会告诉你,别删除远程master分支,因为它是默认的分支……,请移步这里

  • 操作步骤

如果远程只有一个master分支,请你创建一个非master分支,然后推送到远程。
有人会问我为什么?打个比方,你见过上旱厕的时候,给自己脚下站着的板子抽走吗?

脚本类似下面这样

1
2
3
4

git branch the_master_backup

git push origin the_master_backup

此时你查看远程分支应该有两个:master和the_master_backup

设置默认的分支为 the_master_backup

1
2
3
4

git branch -D branch_name //删除本地master分支

git push :master //推送一个空分支,相当于删除远程master分支

然后你在the_master_backup分支上 回滚到你要回滚的commit_id,然后重建master分支并推送到远程,顺便删除the_master_backup分支(包括远程the_master_backup分支)。

1
2
3
4
5
6
7
8
9
10
11
12

git checkout the_master_backup

git reset --hard commit_id

git branch master //重新创建master分支

git push origin master //重新推送master分支

git branch -D the_master_backup //删除本地the_master_backup分支

git push origin :the_master_backup//删除远程the_master_backup分支

遇到的问题

  1. 忘记设置默认分支为非master分支
1
2
3
4
5
6
7
8
9
10
11
12
13
14

remote: error: By default, deleting the current branch is denied, because the ne
xt
remote: error: 'git clone' won't result in any file checked out, causing confusi
on.
remote: error:
remote: error: You can set 'receive.denyDeleteCurrent' configuration variable to

remote: error: 'warn' or 'ignore' in the remote repository to allow deleting the

remote: error: current branch, with or without a warning message.
remote: error:
remote: error: To squelch this message, you can set it to 'refuse'.
...

总结

如果你遇到的是所有提交只有master分支,那么希望我这个博文能帮到你。当然git强大的分支功能你基本也用不到了。

javascript oop 15 min programming

发表于 2015-04-23 | 更新于 2022-08-18 | 分类于 javascript
本文字数: 1.4k | 阅读时长 ≈ 1 分钟

javascript的面向对象15分钟教程

第一种面向对象的写法

创建空对象

1
2

var bill ={};//创建一个空对象

给对象添加属性和方法

1
2
3
4
5

bill.name = "Bill Goat";
bill.work = function (){
console.log("programming....");
};

一步完成上面的两件事

1
2
3
4
5
6
7

var bill ={
name : "Bill Goat";
work : function(){
console.log("programming....");
}
};

访问对象和属性

1
2
3

console.log(bill.name);
bill.work();

方法重写

1
2
3
4
5

bill.name = "Bill Goat";
bill.work =function(who){
console.log("programming for "+who);
};

通过this关键字访问内部属性

1
2
3
4

bill.say = function (){
console.log("bill's name is"+this.name);
};

对象引用

1
2
3
4
5
6

var silly = bill;
console.log(silly.name);
sally.name = "Silly";
console.log(silly.name);
console.log(bill.name);

另一个方式引用

1
2
3
4
5
6
7

bill.name = "Bill Goat";
bill.say();

var sayName = bill.say();
sayName;
sayName();

有意思的地方 :全局属性

1
2
3

var name = "Global";
bill.say();

发现此时输出的是
bill's name is Global

另一种面向对象的写法

定义对象及属性

1
2

function Game(){};

创建对象

1
var DF = new Game();

对象属性

1
DF.title = "星际争霸2";

构造方法

1
2
3
4
5
6
7
8

function Game (title){
this.title = typeof title !== 'undifined' ? title :"";
};

var d3 = new Game("d3");
d3.title;
d3.title ="starcraft2";

this.title = typeof title !== 'undifined' ? title :"";相当于

1
2
3
4
5
6

if(typeof title !== "undifined"){
this.title = title;
}else{
this.title = "";
}

创建一个方法来访问这个属性

1
2
3
4

d3.loveTitle = function (){
console.log("I love "+this.title);
}

更好的写法

1
2
3
4
5

Game.prototype.heartIt = function (){
console.log("I love "+this.title);
}
d3.heartIt();

下次详解javascript的原生对象模型

to be continued~~~~

talk about software engineering

发表于 2015-04-22 | 更新于 2022-08-18 | 分类于 软件工程
本文字数: 432 | 阅读时长 ≈ 1 分钟

关于软件工程的讨论–质量篇

那为什么软件系统的质量不容易高呢?我觉得主要原因是流程不完善。那为什么不完善?需求容易变。为什么容易变?是因为不论程序员自己,还是需求方,其实潜意识都认为自己做的东西是变更成本较低的。

试想一下,为什么没人在盖高楼盖一半变更需求?为什么没人修大桥修一半变更需求?甚至做衣服做一半的时候变更需求,理发到一半变更需求,都会被人认为是不讲理。但是在软件领域,好像这倒成了普遍现象。

因为整个软件系统的实现,都是虚拟的,看不见摸不着,并不消耗什么物料,所以从这个角度想,变起来当然是容易的。但软件系统的架构,其实也跟实体的没本质区别,变更时候要考虑很多关联因素,并不是就那么孤立的看一小块地方,当然,也会有一些不影响全局的变更。打个比方说,如果你在盖房子盖到一半,那变更外墙颜色肯定是要比变更窗户大小容易的。要是想变得太多,估计只好拆了重来。

下面的讨论更加精彩:

A:其实不是流程问题,老板和甲方问题

A:甲方尤其关键

A:尼玛,要8层楼房,付2层费用

……

javascript asynchronous programming learning :event

发表于 2015-04-20 | 更新于 2022-08-18 | 分类于 javascript , 异步
本文字数: 424 | 阅读时长 ≈ 1 分钟

javascript异步编程读书笔记之事件机制

事件的调度

  • 异步执行

setTimeout函数的解释:给定一个回调及n毫秒的延迟,setTimeout会在n毫秒后运行该回调。

代码清单1:

1
2
3
4
5
for (var i = 1; i <= 3; i++) {
setTimeout(function(){
console.log(i); },
0);
};

输出结果:

1
2
3
4
4
4
  • 线程阻塞
    代码清单2:

    1
    2
    3
    4
    5
    6
    var start = new Date;
    setTimeout(function(){
    var end = new Date;
    console.log('Time elapsed:', end - start, 'ms');
    }, 500);
    while (new Date - start < 1000) {};
  • 队列

javascript使用队列的方式来循环处理请求,这种机制被称为事件循环。

use-shorturl and two-dimensional-barcodes to beautify blog

发表于 2015-04-20 | 更新于 2022-08-18 | 分类于 搭建博客
本文字数: 370 | 阅读时长 ≈ 1 分钟

如何使用短网址和二维码简化网站访问

  1. 短网址(shorturl)
    web2.0时代的潮流,借助短网址您可以用简短的网址替代原来冗长的网址,让使用者可以更容易的分享链接。
    这里我使用的是百度的短网址服务:http://dwz.cn/
    1. 访问http://dwz.cn/主页
    2. 输入你的博客地址
      我输入http://jeffsui.github.io/pinghailinfeng_blog/
    3. 复制短网址
  2. 二维码(two-dimensional-barcodes)
    微信时代,不知道二维码的基本都属于外星球人了。
    这里我选择的是草料二维码:
    http://cli.im/
    1. 输入二维码地址
    2. 进行一些基本设置
      包括前景色、背景色、渐变色等等。
    3. 嵌入图片
    4. 选用你喜欢的模板
    5. 保存二维码
  3. 在线存储
    这里我选择国内知名的七牛云存储(七牛不免费了,我迁移到了github)
  4. 在博客中引用图片地址就可以了

我的新文章

发表于 2015-04-17 | 更新于 2022-08-18
本文字数: 75 | 阅读时长 ≈ 1 分钟

#我的新文章

这是我的第一篇在github上的博客。记录下我的工作和生活,慢慢给其他的文章都更新到这里。嬉笑怒骂也好,喜怒哀乐也罢,我就是一个俗人罢了。

1…141516
Jeff Sui

Jeff Sui

153 日志
40 分类
175 标签
RSS
GitHub E-Mail
  • 20201
  • 2to31
  • Boolean1
  • Centos2
  • Exception1
  • GIL1
  • GitGutter1
  • Tkinter1
  • TypeScript2
  • XML2
  • __all__1
  • _thread1
  • app1
  • argparse2
  • array1
  • atexit1
  • bisect1
  • calendar1
  • centos1
  • checkbox1
  • cmath1
  • cmd1
  • code1
  • collections.abc1
  • concurrent1
  • conda1
  • context-manager-types1
  • cookies1
  • copy1
  • coroutines1
  • csv1
  • cygwin1
  • dataclasses1
  • dbm1
  • dict1
  • dictionary1
  • difflib1
  • dis1
  • django4
  • docker3
  • doctest1
  • dom1
  • eclipse1
  • enum1
  • es61
  • esp323
  • esptool1
  • ffmpeg1
  • filecmp1
  • fileinput1
  • fractions1
  • functools1
  • futures1
  • gc1
  • generator1
  • git4
  • gitcafe1
  • github1
  • glob1
  • heapq1
  • hexo2
  • html.parser1
  • http2
  • http.server1
  • ios1
  • iterator1
  • itertools1
  • java3
  • javascript6
  • javaweb2
  • jdk1
  • jira1
  • json1
  • juypter1
  • keyword1
  • linecache1
  • linter1
  • linux2
  • lite-server1
  • m3u81
  • maven4
  • micorpython1
  • micropython2
  • minidom1
  • modulefinder1
  • mongodb1
  • mybatis1
  • mysql1
  • nbextension1
  • nginx1
  • nodejs2
  • ollama1
  • oop1
  • operator1
  • os1
  • os.path1
  • others1
  • pathlib1
  • photo1
  • pickle1
  • pprint1
  • pwd1
  • pycharm1
  • python99
  • python31
  • queue1
  • re1
  • readline1
  • registry2
  • registry-ui2
  • reprlib1
  • rust1
  • sax1
  • sched1
  • select1
  • selectors1
  • selenium3
  • shutil1
  • socket1
  • sort1
  • spring1
  • sqlite32
  • ssm1
  • standar_library1
  • standard_library78
  • statistics1
  • string2
  • sublime1
  • tempfile1
  • this1
  • thread1
  • timeit1
  • turtle2
  • types1
  • uPycraft1
  • unittest1
  • urllib.robotparser1
  • uuid1
  • uv1
  • venv1
  • vite1
  • vscode1
  • vue31
  • weakref1
  • web test2
  • webbrowser1
  • webrepl1
  • windows3
  • xml2
  • 二维码1
  • 办公1
  • 博客3
  • 坑1
  • 字典1
  • 异步1
  • 循环1
  • 感悟1
  • 持续集成1
  • 搭建1
  • 搭建博客1
  • 文章1
  • 新特性1
  • 杂记3
  • 版本管理2
  • 短网址1
  • 禅道1
  • 笔记1
  • 约束1
  • 网易音乐1
  • 美化1
  • 自动化测试1
  • 软件工程1
  • 逆向工程1
  • 闭包1
  • 项目管理2
© 2015 – 2026 Jeff Sui | 827k | 12:32
由 Hexo 强力驱动 v3.9.0
|
主题 – NexT.Gemini v7.1.1
|
0%