Created
June 1, 2018 10:14
-
-
Save chathurangat/84eb7574f5303c0f59af992158a2c6bc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.springframework.context.annotation.Bean; | |
import org.springframework.context.annotation.Configuration; | |
import org.springframework.data.domain.AuditorAware; | |
import org.springframework.data.jpa.repository.config.EnableJpaAuditing; | |
import java.util.Optional; | |
@Configuration | |
@EnableJpaAuditing(auditorAwareRef = "auditorProvider") | |
public class JpaAuditingConfiguration { | |
@Bean | |
public AuditorAware<String> auditorProvider() { | |
/* | |
if you are using spring security, you can get the currently logged username with following code segment. | |
SecurityContextHolder.getContext().getAuthentication().getName() | |
*/ | |
return () -> Optional.ofNullable("chathuranga"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment