Skip to content

Instantly share code, notes, and snippets.

View dantonyuk's full-sized avatar
🏠
Working from home

Dmitry Antonyuk dantonyuk

🏠
Working from home
View GitHub Profile
" A command that creates a scratch buffer.
"
" A scratch buffer is an unlisted buffer that is not assigned to a file,
" and will be wiped out as soon as you're out of it.
"
" 1. Opens a scratch buffer in a new window.
" 2. With a bang (:Scratch!) opens it in the same window.
" 3. Accepts arguments (:Scratch ft=javascript).
" 4. It auto-completes the arguments.

Exception Handling in Spring MVC

Suppose there is a REST UserController managing /user resource:

@RestController
public class UserController {

    @Autowired
    private UserService userService;

Call Transactional Method in the Same Class

Given a repository and a service

// UserRepository.java
public interface UserRepository {
    void createUser(User user);
    void persistUser(User user);
}

Injecting Multiple Beans

Suppose you are implementing a pluggable application. By "pluggable" it is meant that when the application is running, there may be jar-files in the classpath that provide some additional functionality and came from 3rd party sides. It means you do not control them. You do not know how many of them there, you do not know the exact implementations in them.

To provide an entrypoint the application has Plugin interface:

Multiple Beans with the Same Type

The Spring application has an interface

public interface UserService {
  // ...
}

with the only implementation