When you try to use Spring Boot CLI shell completion, you might encounter the following error:
$ . ~/.sdkman/candidates/springboot/current/shell-completion/bash/spring
$ spring -bash: _get_comp_words_by_ref: command not found
-bash: [: -ne: unary operator expected
$
Install 'bash-completion' as follows:
brew install bash-completion
brew tap homebrew/completions
And add the following to '.bash_profile':
if [ -f $(brew --prefix)/etc/bash_completion ]; then
. $(brew --prefix)/etc/bash_completion
fi
Apply the configuration as follows:
source ~/.bash_profile
and now you can see completion candidates as follows:
$ spring
grab init jar shell uninstall war
help install run test version
$
References:
http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#getting-started-installing-the-cli
http://davidalger.com/development/bash-completion-on-os-x-with-brew/
Thursday, September 29, 2016
Saturday, September 24, 2016
Run Spring Boot application with another port with Gradle 'bootRun'
To run Spring Boot application with another port with Gradle 'bootRun', do as follows:
SERVER_PORT=28080 ./gradlew bootRun
SERVER_PORT=28080 ./gradlew bootRun
Friday, September 23, 2016
error: unmappable character for encoding MS949
When you generate Javadoc with Gradle, you might encounter the following error:
error: unmappable character for encoding MS949
Add the following configuration to your `build.gradle`:
javadoc {
options.encoding = 'UTF-8'
}
Reference:
http://stackoverflow.com/questions/25912190/how-to-set-an-encoding-for-the-javadoc-in-gradle
error: unmappable character for encoding MS949
Add the following configuration to your `build.gradle`:
javadoc {
options.encoding = 'UTF-8'
}
Reference:
http://stackoverflow.com/questions/25912190/how-to-set-an-encoding-for-the-javadoc-in-gradle
Tuesday, September 20, 2016
Error:java: Bad service configuration file, or exception thrown while constructing Processor object: javax.annotation.processing.Processor: Provider org.springframework.boot.configurationprocessor.ConfigurationMetadataAnnotationProcessor not found
When you run a test of Spring Boot in IntelliJ, you might be encounter the following error:
Error:java: Bad service configuration file, or exception thrown while constructing Processor object: javax.annotation.processing.Processor: Provider org.springframework.boot.configurationprocessor.ConfigurationMetadataAnnotationProcessor not found
I didn't dig into its root cause but I could detour the problem by removing the content in the file `spring-boot-tools/spring-boot-configuration-processor/src/main/resources/META-INF/services/javax.annotation.processing.Processor` as follows:
#org.springframework.boot.configurationprocessor.ConfigurationMetadataAnnotationProcessor
Error:java: Bad service configuration file, or exception thrown while constructing Processor object: javax.annotation.processing.Processor: Provider org.springframework.boot.configurationprocessor.ConfigurationMetadataAnnotationProcessor not found
I didn't dig into its root cause but I could detour the problem by removing the content in the file `spring-boot-tools/spring-boot-configuration-processor/src/main/resources/META-INF/services/javax.annotation.processing.Processor` as follows:
#org.springframework.boot.configurationprocessor.ConfigurationMetadataAnnotationProcessor
Monday, September 19, 2016
How to change the default Java class comment in IntelliJ
To change the default Java class comment in IntelliJ, do as follows:
IntelliJ IDEA -> Preferences... -> Editor -> File and Code Templates -> Includes -> File Header
IntelliJ IDEA -> Preferences... -> Editor -> File and Code Templates -> Includes -> File Header
Run textsum TensorFlow model
To run `textsum` TensorFlow model, do as follows:
git clone https://github.com/tensorflow/models.git
mkdir textsum_test
cd textsum_test/
ln -s ../models/textsum/data data
ln -s ../models/textsum/ textsum
touch WORKSPACE
bazel build -c opt textsum/...
bazel-bin/textsum/seq2seq_attention \
--mode=train \
--article_key=article \
--abstract_key=abstract \
--data_path=data/data \
--vocab_path=data/vocab \
--log_root=textsum/log_root \
--train_dir=textsum/log_root/train
You can change max run steps with `--max_run_steps`.
Reference:
https://github.com/tensorflow/models/tree/master/textsum
git clone https://github.com/tensorflow/models.git
mkdir textsum_test
cd textsum_test/
ln -s ../models/textsum/data data
ln -s ../models/textsum/ textsum
touch WORKSPACE
bazel build -c opt textsum/...
bazel-bin/textsum/seq2seq_attention \
--mode=train \
--article_key=article \
--abstract_key=abstract \
--data_path=data/data \
--vocab_path=data/vocab \
--log_root=textsum/log_root \
--train_dir=textsum/log_root/train
You can change max run steps with `--max_run_steps`.
Reference:
https://github.com/tensorflow/models/tree/master/textsum
Sunday, September 18, 2016
AssertionError: Empty filelist.
When you run `textsum` TensorFlow model as follows:
bazel-bin/textsum/seq2seq_attention \
--mode=train \
--article_key=article \
--abstract_key=abstract \
--data_path=data/training-* \
--vocab_path=data/vocab \
--log_root=textsum/log_root \
--train_dir=textsum/log_root/train
you might encounter the following error:
AssertionError: Empty filelist.
Replace `--data_path=data/training-*` with `--data_path=data/data` as follows:
bazel-bin/textsum/seq2seq_attention \
--mode=train \
--article_key=article \
--abstract_key=abstract \
--data_path=data/data \
--vocab_path=data/vocab \
--log_root=textsum/log_root \
--train_dir=textsum/log_root/train
Reference:
https://github.com/tensorflow/models/issues/370
bazel-bin/textsum/seq2seq_attention \
--mode=train \
--article_key=article \
--abstract_key=abstract \
--data_path=data/training-* \
--vocab_path=data/vocab \
--log_root=textsum/log_root \
--train_dir=textsum/log_root/train
you might encounter the following error:
AssertionError: Empty filelist.
Replace `--data_path=data/training-*` with `--data_path=data/data` as follows:
bazel-bin/textsum/seq2seq_attention \
--mode=train \
--article_key=article \
--abstract_key=abstract \
--data_path=data/data \
--vocab_path=data/vocab \
--log_root=textsum/log_root \
--train_dir=textsum/log_root/train
Reference:
https://github.com/tensorflow/models/issues/370
ImportError: cannot import name pywrap_tensorflow
When you import `tensorflow`, you might encounter the following error:
>>> import tensorflow
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "tensorflow/__init__.py", line 23, in <module>
from tensorflow.python import *
File "tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
ImportError: cannot import name pywrap_tensorflow
>>>
If you're in the source directory of TensorFlow, moving out from it will solve the issue.
Reference:
https://github.com/tensorflow/tensorflow/issues/3217
>>> import tensorflow
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "tensorflow/__init__.py", line 23, in <module>
from tensorflow.python import *
File "tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
ImportError: cannot import name pywrap_tensorflow
>>>
If you're in the source directory of TensorFlow, moving out from it will solve the issue.
Reference:
https://github.com/tensorflow/tensorflow/issues/3217
Install TensorFlow from source on Mac
To install TensorFlow from source on Mac, do as follows:
git clone https://github.com/tensorflow/tensorflow
brew install bazel swig
sudo easy_install -U six
sudo easy_install -U numpy
sudo easy_install wheel
sudo easy_install ipython
./configure
bazel build -c opt //tensorflow/tools/pip_package:build_pip_package
bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg
sudo pip install /tmp/tensorflow_pkg/tensorflow-0.10.0-py2-none-any.whl
Reference:
https://www.tensorflow.org/versions/r0.10/get_started/os_setup.html#installing-from-sources
git clone https://github.com/tensorflow/tensorflow
brew install bazel swig
sudo easy_install -U six
sudo easy_install -U numpy
sudo easy_install wheel
sudo easy_install ipython
./configure
bazel build -c opt //tensorflow/tools/pip_package:build_pip_package
bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg
sudo pip install /tmp/tensorflow_pkg/tensorflow-0.10.0-py2-none-any.whl
Reference:
https://www.tensorflow.org/versions/r0.10/get_started/os_setup.html#installing-from-sources
Check pip version
To check pip version, do as follows:
$ pip -V
pip 8.1.2 from /Library/Python/2.7/site-packages/pip-8.1.2-py2.7.egg (python 2.7)
$
$ pip -V
pip 8.1.2 from /Library/Python/2.7/site-packages/pip-8.1.2-py2.7.egg (python 2.7)
$
Install pip in Mac
To install pip in Mac, do as follows:
sudo easy_install pip
Reference:
http://stackoverflow.com/questions/17271319/installing-pip-on-mac-os-x
sudo easy_install pip
Reference:
http://stackoverflow.com/questions/17271319/installing-pip-on-mac-os-x
Monday, September 12, 2016
How to exclude modules from Maven test
To exclude modules from Maven test, do as follows:
./mvnw clean test -pl \!:spring-boot-loader-tools,\!:spring-boot-cli,\!:spring-boot-gradle-tests
Reference:
http://stackoverflow.com/questions/5539348/how-to-exclude-a-module-from-a-maven-reactor-build
./mvnw clean test -pl \!:spring-boot-loader-tools,\!:spring-boot-cli,\!:spring-boot-gradle-tests
Reference:
http://stackoverflow.com/questions/5539348/how-to-exclude-a-module-from-a-maven-reactor-build
Friday, September 9, 2016
Run MariaDB as a service using Homebrew in Mac
To run MariaDB as a service using Homebrew in Mac, use the following command:
brew services start mariadb
brew services start mariadb
Install Homebrew on Mac
To install Homebrew on Mac, use the following command:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Reference:
http://brew.sh/
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Reference:
http://brew.sh/
Wednesday, September 7, 2016
Create a new space in OS X El Cpitan
Press `F3` to open Mission Control.
Press `+` button to create a new space.
References:
https://support.apple.com/kb/PH18757?locale=en_US
https://support.apple.com/kb/PH22059?locale=en_US&viewlocale=en_US
Press `+` button to create a new space.
References:
https://support.apple.com/kb/PH18757?locale=en_US
https://support.apple.com/kb/PH22059?locale=en_US&viewlocale=en_US
Concatenate in React
To concatenate in React, do as follows:
<a href={"/restaurants?landmarkId=" + this.props.landmark.id}>{this.props.landmark.name}</a>
Reference:
http://stackoverflow.com/questions/21668025/react-jsx-access-props-in-quotes
<a href={"/restaurants?landmarkId=" + this.props.landmark.id}>{this.props.landmark.name}</a>
Reference:
http://stackoverflow.com/questions/21668025/react-jsx-access-props-in-quotes
Warning: Unknown DOM property class. Did you mean className?
When you use React, you might encounter the following warning as follows:
Warning: Unknown DOM property class. Did you mean className?
Change `class` to `className`.
Warning: Unknown DOM property class. Did you mean className?
Change `class` to `className`.
Set a custom data.sql in Spring Boot
To set a custom `data.sql` in Spring Boot, use `spring.datasource.data` as follows:
spring.datasource.data=classpath*:test/trust_data_20160907.sql
spring.datasource.data=classpath*:test/trust_data_20160907.sql
Backup only table data in MySQL
To backup only table data in MySQL, use `--no-create-info` as follows:
mysqldump -u trust -p db_trust --no-create-info > trust_data_20160907.sql
Reference:
http://stackoverflow.com/questions/5109993/mysqldump-data-only
mysqldump -u trust -p db_trust --no-create-info > trust_data_20160907.sql
Reference:
http://stackoverflow.com/questions/5109993/mysqldump-data-only
Tuesday, September 6, 2016
Uncaught TypeError: client(...).done is not a function
When you use `rest` as follows:
client({
method: 'GET',
path: '/api/employees'
}).done(response => {
this.setState({
employees: response.entity._embedded.employees
});
});
you might get the following error:
Uncaught TypeError: client(...).done is not a function
Changing `done()` to `then()` as follows fixes the error:
client({
method: 'GET',
path: '/api/employees'
}).then(response => {
this.setState({
employees: response.entity._embedded.employees
});
});
Reference:
https://github.com/cujojs/rest
client({
method: 'GET',
path: '/api/employees'
}).done(response => {
this.setState({
employees: response.entity._embedded.employees
});
});
you might get the following error:
Uncaught TypeError: client(...).done is not a function
Changing `done()` to `then()` as follows fixes the error:
client({
method: 'GET',
path: '/api/employees'
}).then(response => {
this.setState({
employees: response.entity._embedded.employees
});
});
Reference:
https://github.com/cujojs/rest
Uncaught TypeError: React.render is not a function
When you run the following code:
const React = require('react');
ReactDOM.render(
<App />,
document.getElementById('react')
);
you might encounter the following error:
Uncaught TypeError: React.render is not a function
Add `react-dom` as follows:
sudo npm install react-dom --save
Import and use it as follows:
const React = require('react');
const ReactDOM = require('react-dom');
ReactDOM.render(
<App />,
document.getElementById('react')
);
Reference:
http://stackoverflow.com/questions/26627665/error-with-basic-react-example-uncaught-typeerror-undefined-is-not-a-function
const React = require('react');
ReactDOM.render(
<App />,
document.getElementById('react')
);
you might encounter the following error:
Uncaught TypeError: React.render is not a function
Add `react-dom` as follows:
sudo npm install react-dom --save
Import and use it as follows:
const React = require('react');
const ReactDOM = require('react-dom');
ReactDOM.render(
<App />,
document.getElementById('react')
);
Reference:
http://stackoverflow.com/questions/26627665/error-with-basic-react-example-uncaught-typeerror-undefined-is-not-a-function
Module build failed: SyntaxError: Unexpected token
When you run `webpack` with React, you might encounter the following error:
Module build failed: SyntaxError: Unexpected token
Install `babel-preset-react` as follows:
sudo npm install babel-preset-react --save
add `query` to `webpack.config.js` as follows:
module.exports = {
...
module: {
loaders: [
...
{
test: /\.js$/,
loader: 'babel',
query: {
presets: ['react']
}
}
]
}
};
Reference:
http://stackoverflow.com/questions/33460420/babel-loader-jsx-syntaxerror-unexpected-token
Module build failed: SyntaxError: Unexpected token
Install `babel-preset-react` as follows:
sudo npm install babel-preset-react --save
add `query` to `webpack.config.js` as follows:
module.exports = {
...
module: {
loaders: [
...
{
test: /\.js$/,
loader: 'babel',
query: {
presets: ['react']
}
}
]
}
};
Reference:
http://stackoverflow.com/questions/33460420/babel-loader-jsx-syntaxerror-unexpected-token
Monday, September 5, 2016
Module build failed: ReferenceError: Promise is not defined
If you use webpack as follows:
webpack ./js/entry.js ./js/bundle.js
you might encounter the following error:
ERROR in /Users/izeye/~/css-loader!./css/style.css
Module build failed: ReferenceError: Promise is not defined
at LazyResult.async (/Users/izeye/node_modules/css-loader/node_modules/postcss/lib/lazy-result.js:237:31)
at LazyResult.then (/Users/izeye/node_modules/css-loader/node_modules/postcss/lib/lazy-result.js:141:21)
at processCss (/Users/izeye/node_modules/css-loader/lib/processCss.js:199:5)
at Object.module.exports (/Users/izeye/node_modules/css-loader/lib/loader.js:24:2)
@ /Users/izeye/~/style-loader!/Users/izeye/~/css-loader!./css/style.css 4:14-91
Upgrade your Node.js to the latest version.
Reference:
https://github.com/webpack/css-loader/issues/145
webpack ./js/entry.js ./js/bundle.js
you might encounter the following error:
ERROR in /Users/izeye/~/css-loader!./css/style.css
Module build failed: ReferenceError: Promise is not defined
at LazyResult.async (/Users/izeye/node_modules/css-loader/node_modules/postcss/lib/lazy-result.js:237:31)
at LazyResult.then (/Users/izeye/node_modules/css-loader/node_modules/postcss/lib/lazy-result.js:141:21)
at processCss (/Users/izeye/node_modules/css-loader/lib/processCss.js:199:5)
at Object.module.exports (/Users/izeye/node_modules/css-loader/lib/loader.js:24:2)
@ /Users/izeye/~/style-loader!/Users/izeye/~/css-loader!./css/style.css 4:14-91
Upgrade your Node.js to the latest version.
Reference:
https://github.com/webpack/css-loader/issues/145
Upgrade Node.js to the latest version
To upgrade Node.js to the latest version, use `n` as follows:
sudo npm install n -g
n stable
Reference:
http://stackoverflow.com/questions/10075990/upgrading-node-js-to-latest-version
sudo npm install n -g
n stable
Reference:
http://stackoverflow.com/questions/10075990/upgrading-node-js-to-latest-version
Convert `.mp4` to `.mp3` using ffmpeg
To convert `.mp4` to `.mp3` using ffmpeg, do as follows:
ffmpeg -i moon_20160905.mp4 -vn -acodec libmp3lame moon_20160905.mp3
Reference:
http://stackoverflow.com/questions/3032280/how-to-convert-mp4-to-mp3-in-java
ffmpeg -i moon_20160905.mp4 -vn -acodec libmp3lame moon_20160905.mp3
Reference:
http://stackoverflow.com/questions/3032280/how-to-convert-mp4-to-mp3-in-java
Install ffmpeg in Ubuntu
To install ffmpeg in Ubuntu, do as follows:
git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg
cd ffmpeg
./configure --disable-yasm --enable-libmp3lame
make
sudo make install
git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg
cd ffmpeg
./configure --disable-yasm --enable-libmp3lame
make
sudo make install
Unknown encoder 'libmp3lame'
When you try to convert `.mp4` to `.mp3` with ffmpeg as follows:
ffmpeg -i moon_20160905.mp4 -vn -acodec libmp3lame moon_20160905.mp3
you might encounter the following error:
Unknown encoder 'libmp3lame'
Add `--enable-libmp3lame` when configuring ffmpeg as follows:
./configure --disable-yasm --enable-libmp3lame
ffmpeg -i moon_20160905.mp4 -vn -acodec libmp3lame moon_20160905.mp3
you might encounter the following error:
Unknown encoder 'libmp3lame'
Add `--enable-libmp3lame` when configuring ffmpeg as follows:
./configure --disable-yasm --enable-libmp3lame
ERROR: libmp3lame >= 3.98.3 not found
When you install ffmpeg with the following command in Ubuntu:
./configure --disable-yasm --enable-libmp3lame
you might encounter the following error:
ERROR: libmp3lame >= 3.98.3 not found
Install `libmp3lame-dev` with the following command:
sudo apt-get install libmp3lame-dev
./configure --disable-yasm --enable-libmp3lame
you might encounter the following error:
ERROR: libmp3lame >= 3.98.3 not found
Install `libmp3lame-dev` with the following command:
sudo apt-get install libmp3lame-dev
Friday, September 2, 2016
Prevent RestTemplate from URL encoding of URL value which has already been encoded
To prevent `RestTemplate` from URL encoding of URL value which has already been encoded, use `UriComponentsBuilder` as follows:
uri = UriComponentsBuilder.fromHttpUrl(url).build(true).toUri();
echoed = restTemplate.getForObject(uri, String.class);
assertThat(echoed).isEqualTo(message);
Note the invocation on `build()` with `encoded` parameter having `true` value.
You can see the full sample code in: https://github.com/izeye/spring-boot-throwaway-branches/blob/rest/src/test/java/learningtest/org/springframework/web/client/RestTemplateTests.java
Reference:
http://stackoverflow.com/questions/28182836/resttemplate-to-not-escape-url
uri = UriComponentsBuilder.fromHttpUrl(url).build(true).toUri();
echoed = restTemplate.getForObject(uri, String.class);
assertThat(echoed).isEqualTo(message);
Note the invocation on `build()` with `encoded` parameter having `true` value.
You can see the full sample code in: https://github.com/izeye/spring-boot-throwaway-branches/blob/rest/src/test/java/learningtest/org/springframework/web/client/RestTemplateTests.java
Reference:
http://stackoverflow.com/questions/28182836/resttemplate-to-not-escape-url
Subscribe to:
Posts (Atom)