To show plugins' versions,
You can use the following command:
gradle dependencies
If you apply `jacoco` plugin as follows:
apply plugin: 'jacoco'
you will see the following result:
jacocoAgent - The Jacoco agent to use to get coverage data.
\--- org.jacoco:org.jacoco.agent:0.6.2.201302030002
jacocoAnt - The Jacoco ant tasks to use to get execute Gradle tasks.
\--- org.jacoco:org.jacoco.ant:0.6.2.201302030002
+--- org.jacoco:org.jacoco.core:0.6.2.201302030002
| \--- org.ow2.asm:asm-all:4.1
+--- org.jacoco:org.jacoco.report:0.6.2.201302030002
| +--- org.jacoco:org.jacoco.core:0.6.2.201302030002 (*)
| \--- org.ow2.asm:asm-all:4.1
\--- org.jacoco:org.jacoco.agent:0.6.2.201302030002
Reference:
https://gradle.org/docs/current/userguide/tutorial_gradle_command_line.html
Wednesday, April 22, 2015
How to reference test classes in a depedent project in Gradle
If you have the following depedency:
compile project(":some-common")
you can't use `some-common`'s test classes.
Add the following dependency for test classes:
testCompile project(":some-common").sourceSets.test.output
Reference:
http://stackoverflow.com/questions/5644011/multi-project-test-dependencies-with-gradle
compile project(":some-common")
you can't use `some-common`'s test classes.
Add the following dependency for test classes:
testCompile project(":some-common").sourceSets.test.output
Reference:
http://stackoverflow.com/questions/5644011/multi-project-test-dependencies-with-gradle
Tuesday, April 14, 2015
How to `cherry-pick` a commit in a remote branch in Git
In Git, to `cherry-pick` a commit in a remote branch, do the following:
git fetch
git checkout issue-1004
git checkout master
git cherry-pick a2d64cb52f7ef25ad52f18667ae081cddccc7153
Reference:
http://stackoverflow.com/questions/13788945/how-to-cherry-pick-from-a-remote-branch
git fetch
git checkout issue-1004
git checkout master
git cherry-pick a2d64cb52f7ef25ad52f18667ae081cddccc7153
Reference:
http://stackoverflow.com/questions/13788945/how-to-cherry-pick-from-a-remote-branch
How to checkout a remote branch in Git
In Git, to checkout a remote branch, do the following:
git fetch
git checkout issue-1004
Reference:
http://stackoverflow.com/questions/1783405/checkout-remote-git-branch
git fetch
git checkout issue-1004
Reference:
http://stackoverflow.com/questions/1783405/checkout-remote-git-branch
How to show remote branches in Git
In Git, to show remote branches, use the following command:
git branch -a
or
git remote show origin
Reference:
http://gitready.com/intermediate/2009/02/13/list-remote-branches.html
git branch -a
or
git remote show origin
Reference:
http://gitready.com/intermediate/2009/02/13/list-remote-branches.html
Wednesday, April 8, 2015
Caused by: java.io.FileNotFoundException: class path resource [repository/naver/keyword/keyword_map.txt] cannot be resolved to absolute file path because it does not reside in the file system: jar:file:/xxx.jar!/xxx.txt
When you try to access a file in a .jar file as follows:
String resourceLocation = "classpath:xxx.txt";
File file = ResourceUtils.getFile(resourceLocation);
you will encounter the following exception:
Caused by: java.io.FileNotFoundException: class path resource [repository/naver/keyword/keyword_map.txt] cannot be resolved to absolute file path because it does not reside in the file system: jar:file:/xxx.jar!/xxx.txt at org.springframework.util.ResourceUtils.getFile(ResourceUtils.java:212)
You can use the following code instead:
String resourceLocation = "/xxx.txt";
InputStream is = getClass().getResourceAsStream(resourceLocation);
String resourceLocation = "classpath:xxx.txt";
File file = ResourceUtils.getFile(resourceLocation);
you will encounter the following exception:
Caused by: java.io.FileNotFoundException: class path resource [repository/naver/keyword/keyword_map.txt] cannot be resolved to absolute file path because it does not reside in the file system: jar:file:/xxx.jar!/xxx.txt at org.springframework.util.ResourceUtils.getFile(ResourceUtils.java:212)
You can use the following code instead:
String resourceLocation = "/xxx.txt";
InputStream is = getClass().getResourceAsStream(resourceLocation);
Monday, April 6, 2015
Caused by: net.sf.ehcache.CacheException: Another unnamed CacheManager already exists in the same VM.
When you run unit tests (strictly speaking, integration tests),
you can encounter the following exception:
Caused by: net.sf.ehcache.CacheException: Another unnamed CacheManager already exists in the same VM. Please provide unique names for each CacheManager in the config or do one of following:
1. Use one of the CacheManager.create() static factory methods to reuse same CacheManager with same name or create one if necessary
2. Shutdown the earlier cacheManager before creating new one with same name.
The source of the existing CacheManager is: InputStreamConfigurationSource [stream=java.io.BufferedInputStream@6fd1660]
at net.sf.ehcache.CacheManager.assertNoCacheManagerExistsWithSameName(CacheManager.java:628)
at net.sf.ehcache.CacheManager.init(CacheManager.java:392)
You can fix it by setting `shared` of `EhCacheManagerFactoryBean` to `true` as follows:
@Bean
public EhCacheManagerFactoryBean ehcache() {
EhCacheManagerFactoryBean ehCacheManagerFactoryBean = new EhCacheManagerFactoryBean();
ehCacheManagerFactoryBean.setConfigLocation(new ClassPathResource("ehcache/ehcache.xml"));
ehCacheManagerFactoryBean.setShared(true);
return ehCacheManagerFactoryBean;
}
Reference:
http://stackoverflow.com/questions/10013288/another-unnamed-cachemanager-already-exists-in-the-same-vm-ehcache-2-5
you can encounter the following exception:
Caused by: net.sf.ehcache.CacheException: Another unnamed CacheManager already exists in the same VM. Please provide unique names for each CacheManager in the config or do one of following:
1. Use one of the CacheManager.create() static factory methods to reuse same CacheManager with same name or create one if necessary
2. Shutdown the earlier cacheManager before creating new one with same name.
The source of the existing CacheManager is: InputStreamConfigurationSource [stream=java.io.BufferedInputStream@6fd1660]
at net.sf.ehcache.CacheManager.assertNoCacheManagerExistsWithSameName(CacheManager.java:628)
at net.sf.ehcache.CacheManager.init(CacheManager.java:392)
You can fix it by setting `shared` of `EhCacheManagerFactoryBean` to `true` as follows:
@Bean
public EhCacheManagerFactoryBean ehcache() {
EhCacheManagerFactoryBean ehCacheManagerFactoryBean = new EhCacheManagerFactoryBean();
ehCacheManagerFactoryBean.setConfigLocation(new ClassPathResource("ehcache/ehcache.xml"));
ehCacheManagerFactoryBean.setShared(true);
return ehCacheManagerFactoryBean;
}
Reference:
http://stackoverflow.com/questions/10013288/another-unnamed-cachemanager-already-exists-in-the-same-vm-ehcache-2-5
Thursday, April 2, 2015
{"cause":null,"message":"No @Param annotation found on query method findByLastName for parameter null"}
When you use Spring Data REST and get the following URL:
http://localhost:18080/api/customers/search/findByLastName?lastName=Bauer
you can encounter the following error:
{"cause":null,"message":"No @Param annotation found on query method findByLastName for parameter null"}
Change the following code:
List<Customer> findByLastName(String lastName);
to the following code:
List<Customer> findByLastName(@Param("lastName") String lastName);
http://localhost:18080/api/customers/search/findByLastName?lastName=Bauer
you can encounter the following error:
{"cause":null,"message":"No @Param annotation found on query method findByLastName for parameter null"}
Change the following code:
List<Customer> findByLastName(String lastName);
to the following code:
List<Customer> findByLastName(@Param("lastName") String lastName);
Subscribe to:
Posts (Atom)