小米`s Blog

人可以此生平凡,但不该平庸一生。


  • 首页

  • 关于

  • 标签

  • 分类

  • 归档

  • 公益404

SpringBoot项目在IDEA中实现热部署

发表于 2018-07-29 | 更新于: 2018-07-30 | 分类于 工作 , Springboot | 热度: °C
字数统计: 232 字 | 阅读时长 ≈ 1 分钟

版本: Intellij IDEA 2017.3

1. 引入插件

引入热加载的插件,springboot 1.3开始就有的…

1
2
3
4
5
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>

project 中添加spring-boot-maven-plugin,主要在eclipse中起作用,idea不需要加此配置。
SpringBoot 项目的话,应该是有此配置,加 里面的内容即可。

1
2
3
4
5
6
7
8
9
10
11
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
</configuration>
</plugin>
</plugins>
</build>

2. IDEA(2017.3) 配置

  1. 点击: File-> Settings -> Build ,Execution,Deployment -> Compiler

    Mac版IDEA,使用快捷键 command + , 打开 Preferences
    定位到-> Build ,Execution,Deployment -> Compiler

Compiler.png

选中 Build project automatically,然后点击 OK 保存退出。

  1. 使用组合键:Shift+ALT+Ctrl+/ ,选择Registry,回车

    Mac版 command + option +shift +/

Registry-01.png
Registry-02.png

搜索 complier.automake.allow.when.app.running ,找到后,勾选 ☑️ 退出即可。

  1. 禁用浏览器缓存
    按F12(更多工具—->开发者工具),找到network,勾选Disable Cache。

Git常见安装问题

发表于 2018-01-31 | 更新于: 2018-01-31 | 分类于 工作 , Git | 热度: °C
字数统计: 390 字 | 阅读时长 ≈ 2 分钟

配置

配置用户名(提交时候会引用)

config --global user.name "yourusername" ``` 『--global表示是全局的』
1
2
3

#### 配置邮箱
> ```git config --golbal user.email "youremail"

冲突merge使用版本

config --global merge.tool "kdiff3"``` (没装kdiff3忽略本行)
1
2
3

#### 让Git不要管Windows/Unix换行符转换的事
> ```git config --global core.autocrlf false

编码配置

避免git gui中的中文乱码

config --global gui.encoding utf-8```
1
2
3

#### 避免git status显示的中文名乱码
> ```git config --global core.quotepath off

windows区分大小写设置

git config --global core.ignorecase false


使用命令: git status 查看状态

git init 初始化仓库
git add . 将所有文件(除去忽略的文件,添加到仓库中)
git commit -am “添加注释” 提交文件到仓库


推送到远程仓库

1.复制远程仓库地址 git@gitee.com:xxxxx/xxxx.git 添加远程仓库

git remote add origin git@gitee.com:xxxxx/xxxx.git

2.查看分支

git branch
git push -u[-f] origin master (-f表示强制更新)

提交代码到远程仓库

  1. 先执行下 git pull 【拉取一下】
  2. 执行 git push -u origin master
  3. 如果还报错的话 git push -u -f origin master 【强制替换更新】

——主流的开发模式支线开发 主干发布——
查看本地分支git branch
查看远程分支git branch -r
— 创建分支
git checkout -b v1.0 origin/master 【 -b表示创建新的分支 origin/master 表示v1.0在远程 master的基础上 】
发部到远程仓库
git push origin HEAD -u 远程会有两个仓库 master v1.0

git checkout [master/v1.0]切换分支

Git SSH 配置(码云+Github)

发表于 2018-01-31 | 更新于: 2018-01-31 | 分类于 工作 , Git | 热度: °C
字数统计: 137 字 | 阅读时长 ≈ 1 分钟

码云配置

1.在linux的命令行下,或者是windows上Git Bash命令行窗口中键入

ssh-keygen -t rsa -C "xxxx@xx.com"

2.一直按回车(Enter),不要输入任何密码之类,生成 ssh key pair

3.ssh-add ~/.ssh/id_rsa
如果出现 Could not open a connection to your authentiacation agent 执行 eval `ssh-agent`
在执行 ssh-add ~/.ssh/rsa成功 ssh-add l就有新加的rsa了

4.cat ~/.ssh/id_rsa.pub(查看)

5.将公钥复制出来

6.进入码云-个人设置-SSH公钥配置,把复制的东西加进去提交 。

Android 定时器、定时任务整理

发表于 2018-01-30 | 更新于: 2018-01-30 | 分类于 工作 , Android | 热度: °C
字数统计: 712 字 | 阅读时长 ≈ 4 分钟

1. ScheduledExecutorService

  1. Timer不支持多线程。全部挂在Timer下的任务都是单线程的,任务仅仅能串行运行。假设当中一个任务运行时间过长。会影响到其它任务的运行,然后就可能会有各种接踵而来的问题。

  2. Timer的线程不捕获异常。TimerTask假设抛出异常,那么Timer唯一的进程就会挂掉,这样挂在Timer下的全部任务都会无法继续运行。

    为了弥补Timer的缺陷,jdk1.5中引入了并发包。这里面提供的ScheduledExecutorService。详细实现类是:ScheduledThreadPoolExecutor。ScheduledThreadPoolExecutor支持多线程。同一时候在线程中对异常进行了捕获。

    使用实例:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
public class Task2 extends TimerTask{

@SuppressWarnings("deprecation")
@Override
public void run() {
System.out.println("----task2 start--------"+new Date().toLocaleString());
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("----5s later, task2 end--------"+new Date().toLocaleString());
}
}

public static void main(String[] args) {

ScheduledExecutorService pool = Executors.newScheduledThreadPool(2);//启用2个线程

Task1 t1 = new Task1();
// 马上运行,任务消耗3秒。运行结束后等待2秒。【有空余线程时】,再次运行该任务
pool.scheduleWithFixedDelay(t1, 0, 2, TimeUnit.SECONDS);

// 马上运行,任务消耗5秒,运行结束后等待2秒。【有空余线程时】,再次运行该任务
Task2 t2 = new Task2();
pool.scheduleWithFixedDelay(t2, 0, 2, TimeUnit.SECONDS);
}

运行结果:
运行结果.png

这样任务之间就不会相互影响了。并且能够同一时候运行。可是线程数量要设置好了。

在Android 使用也是如此:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
private ScheduledExecutorService scheduleTaskExecutor;

scheduleTaskExecutor = new ScheduledThreadPoolExecutor(1, new ThreadFactory() {
private AtomicInteger atoInteger = new AtomicInteger(0);

@Override
public Thread newThread(Runnable r) {
Thread t = new Thread(r);
t.setName("App-Thread" + atoInteger.getAndIncrement());
return t;
}
});

// 开启执行
private void startScheduledTask() {
scheduleTaskExecutor.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
Message message = new Message();
message.what = UPDATE_DATA;
mHandler.sendMessage(message);
}
}, 1, 3, TimeUnit.SECONDS);

}

@Override
protected void onDestroy() {
super.onDestroy();
if (scheduleTaskExecutor != null && !scheduleTaskExecutor.isShutdown()) {
scheduleTaskExecutor.shutdown();
}
}

2. Timer定时器

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
private Timer mTimer;
mTimer = new Timer();

// 开启任务
private void startTimerTask() {
mTimer.schedule(new TimerTask() {
@Override
public void run() {
Message message = new Message();
message.what = UPLOAD_RIDING_LBS;
mMapLocHandler.sendMessage(message);
}
}, 1000, 3000);
}

// 取消任务
private void cancelTask(){
if (mTimer != null) {
mTimer.cancel();
}
}

3.定时器的三种方法

  1. 第一种方法:Thread.sleep();方法
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Runnable runnable = new Runnable() {
@Override
public void run() {
while (true) {
mHandler.sendEmptyMessage(0);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
};
new Thread(runnable).start();
  1. 第二种方法:Handler的postDelay()方法
1
2
3
4
5
6
7
8
9
10
final Runnable runnable = new Runnable() {
@Override
public void run() {
if (isStart2) {
mHandler.sendEmptyMessage(0);
mHandler.postDelayed(this, 1000);
}
}
};
mHandler.postDelayed(runnable, 1000);
  1. 第三种:Timer和TimerTask
1
2
3
4
5
6
7
8
 private Timer timer = new Timer();
private TimerTask timerTask = new TimerTask() {
@Override
public void run() {
mHandler.sendEmptyMessage(0);
}
};
timer.schedule(timerTask, 1000, 1000);
hello2018.jpg

AndroidStudio 3.0的一些变化

发表于 2017-12-18 | 更新于: 2017-12-18 | 分类于 工作 , Android | 热度: °C
字数统计: 102 字 | 阅读时长 ≈ 1 分钟

说明:文章和解决方案均转载各大网站和论坛,仅方便自己和他人遇到此类问题时快速解决。
如果链接/文章侵犯了您的版权和意愿,请下方留言,我会立即删除。

  1. [#CSDN#] Android Studio 3.0 的一些变化
  2. [#CSDN#] Gradle sync failed
  3. [#简书#] Android 构建速度
  4. [#CSDN#] Error:All flavors must now belong to a named flavor dimension

Mac版PHPStorm-调整内存限制

发表于 2017-12-12 | 更新于: 2017-12-12 | 分类于 工作 , 日志 | 热度: °C
字数统计: 114 字 | 阅读时长 ≈ 1 分钟

调整方法

参考链接 https://segmentfault.com/a/1190000003960160

1
2
3
4
5
6
7
8
9
# 用的是 mac osx,编辑 phpstorm 的启动配置文件,其他平台根据情况选择:
sudo vim /Applications/PhpStorm.app/Contents/bin/phpstorm.vmoptions

# 修改参数,根据具体需要修改即可,一般修改 -Xmx(即最大可占内存)即可
-Xms512m
-Xmx2048m
-XX:MaxPermSize=350m
-XX:ReservedCodeCacheSize=240m
-XX:+UseCompressedOops

修改 Webstorm 同理:

1
2
3
4
5
-Xms512m
-Xmx2048m
-XX:MaxPermSize=350m
-XX:ReservedCodeCacheSize=240m
-XX:+UseCompressedOops

mozjpeg pre-build test failed

发表于 2017-11-22 | 更新于: 2017-11-22 | 分类于 工作 , 日志 | 热度: °C
字数统计: 281 字 | 阅读时长 ≈ 2 分钟

OS X 10.13.1

nasm -v

NASM version 0.98.40 (Apple Computer, Inc. build 11) compiled on Oct 11 2017

执行 npm install后发现控制台出现如下信息:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
mozjpeg@4.1.1 postinstall /Applications/XAMPP/xamppfiles/htdocs/bright-cms/node_modules/mozjpeg
node lib/install.js

⚠ The `/Applications/XAMPP/xamppfiles/htdocs/bright-cms/node_modules/mozjpeg/vendor/cjpeg` binary doesn't seem to work correctly
⚠ mozjpeg pre-build test failed
ℹ compiling from source
✖ Error: autoreconf -fiv && ./configure --disable-shared --prefix="/Applications/XAMPP/xamppfiles/htdocs/bright-cms/node_modules/mozjpeg/vendor" --bindir="/Applications/XAMPP/xamppfiles/htdocs/bright-cms/node_modules/mozjpeg/vendor" --libdir="/Applications/XAMPP/xamppfiles/htdocs/bright-cms/node_modules/mozjpeg/vendor" && make --jobs=4 && make install --jobs=4
Command failed: autoreconf -fiv
/bin/sh: autoreconf: command not found
at ChildProcess.exithandler (child_process.js:271:12)
at emitTwo (events.js:125:13)
at ChildProcess.emit (events.js:213:7)
at maybeClose (internal/child_process.js:927:16)
at Socket.stream.socket.on (internal/child_process.js:348:11)
at emitOne (events.js:115:13)
at Socket.emit (events.js:210:7)
at Pipe._handle.close [as _onclose] (net.js:547:12)

如下是问题解决的链接地址

  1. Update Xcode command line tools to latest release
  2. brew install nasm (I was using the bundled OS X version 0.98.40, now using 2.11.08)
  3. npm cache clean
  4. npm install

注:PNG reference library: libpng

  1. PNG reference library: libpng
  2. Mac下ImageMagick安装(libpng)
  3. Mac环境安装imagemagick

上传library到自己创建的maven仓库

发表于 2017-11-22 | 更新于: 2017-11-22 | 分类于 工作 , Library | 热度: °C
字数统计: 151 字 | 阅读时长 ≈ 1 分钟

根目录build添加

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

buildscript {

repositories {

jcenter()

}

dependencies {

classpath 'com.android.tools.build:gradle:2.2.2'

classpath 'com.novoda:bintray-release:0.3.4'

}

需要上传Library的build添加

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

apply plugin: 'com.novoda.bintray-release'

publish {

userOrg = '' //bintray注册的用户名

groupId = '' //compile引用时的第1部分groupId

artifactId = '' //compile引用时的第2部分项目名

publishVersion = '1.0.0' //compile引用时的第3部分版本号

desc = ''

website = ''

}

最后打开Termainal执行命令

发布到bintary 命令

./gradlew clean build bintrayUpload -PbintrayUser=用户名 -PbintrayKey=自己KEY -PdryRun=false

Mac系统更新后Git不可用,提示missing-xcrun-at-xxx

发表于 2017-11-12 | 更新于: 2017-11-23 | 分类于 工作 , 日志 | 热度: °C
字数统计: 213 字 | 阅读时长 ≈ 1 分钟

记录于2017-11-13:更新后 MacOS 版本为 10.13.1

今天系统升级后,发现原来开发 IDE 里的 git 托管项目,没法push和pull 操作了,然后看到控制台里提示信息:

error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at:link
1
2
3
4
5
6
7

百度一圈后,找到了解决方案,特摘录一份备份。

据说苹果每个版本更新后都有这样的问题,原因是每次安装更醒后,Xcode 都被卸载了。通过终端重新安装的Xcode命令行工具使用(其实这里安装的是Command Line Tools,Command Line Tools是在Xcode中的一款工具)

## 1 :命令行安装
>``` xcode-select --install

按照提示安装完毕即可,安装成功后,重新查看 git 版本信息:

git version

至此,应该就算 OK 了,简单省事。

12
小米`s

小米`s

人可以此生平凡,但不该平庸一生。

20 日志
12 分类
10 标签
GitHub 知乎 简书 掘金
© 2020 小米`s
津ICP备17007097号-1 博客全站共 6.3k 字