diff --git a/whatsmars-spring-boot/src/main/java/org/hongxi/whatsmars/spring/boot/controller/InitRunner.java b/whatsmars-spring-boot/src/main/java/org/hongxi/whatsmars/spring/boot/controller/InitRunner.java index 9c079440..6cb90978 100644 --- a/whatsmars-spring-boot/src/main/java/org/hongxi/whatsmars/spring/boot/controller/InitRunner.java +++ b/whatsmars-spring-boot/src/main/java/org/hongxi/whatsmars/spring/boot/controller/InitRunner.java @@ -2,6 +2,8 @@ import org.hongxi.whatsmars.spring.boot.async.MessageService; import org.hongxi.whatsmars.spring.boot.dao.UserMapper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.CommandLineRunner; import org.springframework.core.annotation.Order; @@ -13,6 +15,9 @@ @Component @Order(value = 1) public class InitRunner implements CommandLineRunner { + + private final Logger logger = LoggerFactory.getLogger(getClass()); + @Autowired private UserMapper userMapper; @Autowired @@ -20,7 +25,7 @@ public class InitRunner implements CommandLineRunner { @Override public void run(String... args) throws Exception { - System.out.println("init......createIfNotExistsTable"); + logger.info("init......createIfNotExistsTable"); userMapper.createIfNotExistsTable(); for (int i = 0; i < 10; i++) { diff --git a/whatsmars-spring-boot/src/main/java/org/hongxi/whatsmars/spring/boot/controller/UserController.java b/whatsmars-spring-boot/src/main/java/org/hongxi/whatsmars/spring/boot/controller/UserController.java index caa98a82..ff741f7b 100644 --- a/whatsmars-spring-boot/src/main/java/org/hongxi/whatsmars/spring/boot/controller/UserController.java +++ b/whatsmars-spring-boot/src/main/java/org/hongxi/whatsmars/spring/boot/controller/UserController.java @@ -1,7 +1,6 @@ package org.hongxi.whatsmars.spring.boot.controller; import com.github.pagehelper.Page; -import org.apache.logging.log4j.LogManager; import org.hongxi.whatsmars.common.result.Result; import org.hongxi.whatsmars.common.result.ResultHelper; import org.hongxi.whatsmars.spring.boot.common.ReturnItemUtils; @@ -9,6 +8,8 @@ import org.hongxi.whatsmars.spring.boot.exception.AppException; import org.hongxi.whatsmars.spring.boot.model.User; import org.hongxi.whatsmars.spring.boot.service.UserService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.*; @@ -23,7 +24,7 @@ @RequestMapping("/user") public class UserController { - private final org.apache.logging.log4j.Logger logger = LogManager.getLogger(getClass()); + private final Logger logger = LoggerFactory.getLogger(getClass()); @Autowired private UserService userService; diff --git a/whatsmars-spring-boot/src/main/java/org/hongxi/whatsmars/spring/boot/exception/AppExceptionHandler.java b/whatsmars-spring-boot/src/main/java/org/hongxi/whatsmars/spring/boot/exception/AppExceptionHandler.java index 720520e1..aaadcc81 100644 --- a/whatsmars-spring-boot/src/main/java/org/hongxi/whatsmars/spring/boot/exception/AppExceptionHandler.java +++ b/whatsmars-spring-boot/src/main/java/org/hongxi/whatsmars/spring/boot/exception/AppExceptionHandler.java @@ -24,7 +24,7 @@ @ControllerAdvice(annotations = { RestController.class, Controller.class}) public class AppExceptionHandler { - private Logger logger = LoggerFactory.getLogger(getClass()); + private final Logger logger = LoggerFactory.getLogger(getClass()); /** * 业务异常处理,直接返回异常信息提示 diff --git a/whatsmars-spring-boot/src/main/java/org/hongxi/whatsmars/spring/boot/service/impl/UserServiceImpl.java b/whatsmars-spring-boot/src/main/java/org/hongxi/whatsmars/spring/boot/service/impl/UserServiceImpl.java index 5fece057..6869b908 100644 --- a/whatsmars-spring-boot/src/main/java/org/hongxi/whatsmars/spring/boot/service/impl/UserServiceImpl.java +++ b/whatsmars-spring-boot/src/main/java/org/hongxi/whatsmars/spring/boot/service/impl/UserServiceImpl.java @@ -5,8 +5,8 @@ import org.hongxi.whatsmars.spring.boot.dao.UserMapper; import org.hongxi.whatsmars.spring.boot.model.User; import org.hongxi.whatsmars.spring.boot.service.UserService; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -19,7 +19,7 @@ @Service("userService") public class UserServiceImpl implements UserService { - private final Logger logger = LogManager.getLogger(getClass()); + private final Logger logger = LoggerFactory.getLogger(getClass()); @Autowired private UserMapper userMapper;