Table of Contents
- Write parameterized tests with autowiring dependency injection in Spring Boot 1
- Setting a TTL for @Cacheable
@NoArgsConstructor(access = AccessLevel.PRIVATE)# Display available updates
mvn versions:display-dependency-updates
# Execute only the tests in SomeTestClass
mvn test -Dtest=SomeTestClass
# Stop immediately after the first failing test
mvn test -Dsurefire.skipAfterFailureCount=1# Tasks runnable from root project
gradle tasks
# Build displaying more logging information
gradle -i build
# Executes only the tests in SomeTestClass
gradle test --tests SomeTestClass
# Executes only one specific test method
gradle test --tests SomeTestClass.specificMethod
# Stop immediately after the first failing test
gradle test --fail-fastSince Gradle version 3 plugins can be specified through the plugins DSL:
plugins {
id 'java'
}The plugins {} block must be a top level statement in the buildscript and cannot be nested inside another construct.
Both in Gradle and Gradle Wrapper, add the following line to your ./gradle.properties:
org.gradle.console=rich
Add the following block to your ./build.gradle:
test {
testLogging.exceptionFormat = 'full'
}Use Gradle Use Latest Versions Plugin .
SDKMAN allows to install multiple versions of Java and conveniently switch between them.
-
cd into the base directory of your project
-
use SDKMAN to switch to the desired Java version
-
run
sdk env init(this will generate a.sdkmanrcfile in the current directory, pre-populated with the Java version in use)
From now on when you enter your project base directory you can switch to the chosen Java version by simply running:
$ sdk envSet the folling in your ~/.sdkman/etc/config:
sdkman_auto_env=true Flyway is an open-source database migration tool: it is based around just 7 basic commands: migrate, clean, info, validate, undo, baseline and repair.
Migrations files names must comply with Flyway naming pattern.
To check that flyway is configured correctly and to see the list of pending migrations run:
flyway infoTo run the pending migrations run:
flyway migrateRolling back/undo migrations is availble only for Flyway Pro or Enterprise Edition. To roll back with the Community Edition you need to:
-
locally:
-
run
flyway clean -
move the migrations you want to roll back out of
flyway.locations -
run
flyway migrate -
move the migrations you rolled back in
flyway.locations
-
-
staging/production:
-
write migrations which revert the changes made in the migrations you want to roll back
-
commit, push and deploy the migrations
-
For furthern info check the Flyway documentation.
The following steps outline a basic setup for working with Java in NeoVim, enabling these key features: syntax highlighting, code navigation, code refactoring, code completion, formatting, debugging, diagnostics (errors, warnings, etc.), hover information, auto imports.
-
Install SDKMAN with
curl -s "https://get.sdkman.io" | bash -
Install the latest stable version of Java with
sdk install java -
Install NeoVim
-
Install LazyVim
-
Create
~/.config/nvim/lua/plugins/treesitter.luaand paste in the following:return { "nvim-treesitter/nvim-treesitter", opts = { ensure_installed = { "java", }, }, }
-
Run
:Mason, selectjdtlsand pressito install it, go up to the top and wait until you see it is installed. -
Create
~/.config/nvim/lua/plugins/jdtls.luaand paste in the following:return { { "mfussenegger/nvim-jdtls", ft = "java", } }
Support to Groovy might be needed for example if you are using the Spock test framework.
-
Append
"groovy",to theensure_installedobject in thetreesitter.luafile mentioned above. -
To be continued...
google-java-format is not supported by eclipse.jdt.ls (see redhat-developer/vscode-java#663 & redhat-developer/vscode-java#419) but given that it's an executable you should be able to use it with formatprg, see :help formatprg.
To be continued...
Install as a snap package to have your installation always up to date.
Alternatively, install manually with the following steps:
-
Download IntelliJ IDEA
-
Unpack the
tar.gzfile to an empty directory using the following command:tar -xzf idea-2020.2.1.tar.gz
-
Run
bin/idea.sh
# Find files which contain two strings on any line
(string1)[\s\S]*(string2)|\2[\s\S]*\1
# Find files which contain two strings on the same line
\Qstring1\E.*\Qstring2\E
# Find in files excluding packages and imports statements
^(?!import|package).*wordToSearchKeymap > Navigate > Back | Forward > right click > Add mouse shortcut
Editor > General > Change font size with Ctrl+Mouse Wheel
Editor > General > Editor Tabs > Tab limit = 100
| Key | Command | Notes |
|---|---|---|
Ctrl+Shift+A |
Find action | Enables you to search for commands and settings across all menus and tools (similarly to VsCode "Show all commands" - Ctrl+Shift+P) |
Shift Shift |
Search for a target by name (Search everywhere) | Find any item in the project or outside of it by its name: files, actions, classes, symbols, settings, and UI elements. (similar - but more powerful - than VsCode "Go to File..., Quick Open" - Ctrl+P) |
Ctrl+Shift+F |
Find in path | Search for a text string within a project |
Ctrl+E |
Open Recent files | |
Ctrl+Shift+E |
Open Recent Edited files | |
Ctrl+F12 |
Locate a code element | Open the structure view popup allowing to jump to the desired element |
Ctrl+N |
Navigate to class | |
Ctrl+Shift+N |
Navigate to file by file name | |
Ctrl+Alt+Shift+N |
Navigate to symbol in project (class, method, etc) |