@Component // 1, the tools declared as spring assembly, this must not be forgotten public class TestUtils { // 2, automatic injection @Autowired private ItemService itemService; // 3, the beginning of the current class static public static TestUtils testUtils; // 4, in the method annotate @PostConstruct, such a process will be performed after the container Spring Bean initialization (Note: Bean initialization includes, examples of Bean, Bean properties and assembled (dependency injection)). @PostConstruct public void init() { testUtils = this; testUtils.itemService = this.itemService; } // 5, the method used in example utils tools or service mapper interface with "testUtils.xxx. Method" on it public static void test(Item record) { // 6, call the service method testUtils.itemService.insert(record); } }