Spring Data JPA: LIKE with OR query

@RepositoryRestResource public interface ProductRepository extends JpaRepository<Product, String> { List<Product> findByTitleContainingIgnoreCaseOrIdContainingIgnoreCase( @Param("q") String name, @Param("q") String id); }@RepositoryRestResource public interface ProductRepository extends JpaRepository<Product, String> { List<Product> findByTitleContainingIgnoreCaseOrIdContainingIgnoreCase( @Param("q") String name, @Param("q") String id); } Request path: GET https://localhost:8443/api/products/search/findByTitleContainingIgnoreCaseOrIdContainingIgnoreCase?q=…GET https://localhost:8443/api/products/search/findByTitleContainingIgnoreCaseOrIdContainingIgnoreCase?q=… If we need shorter request path: // GET https://localhost:8443/api/products/search/custom?q=… @RestResource(path = "custom") List<Product> findByTitleContainingIgnoreCaseOrIdContainingIgnoreCase( @Param("q") String name, Read more about Spring Data JPA: LIKE with OR query[…]

Active Directory/LDAP authentication with Spring Boot

package net.marioosh.ldapdemo;   import java.util.Arrays; import java.util.Collection;   import org.springframework.context.annotation.Configuration; import org.springframework.ldap.core.DirContextOperations; import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.authority.SimpleGrantedAuthority; import org.springframework.security.ldap.userdetails.LdapAuthoritiesPopulator;   @Configuration public class SecurityConfig extends WebSecurityConfigurerAdapter {   @Override protected void configure(HttpSecurity http) throws Exception { http.authorizeRequests() .anyRequest() .fullyAuthenticated() .and().formLogin(); }   @Override public void configure(AuthenticationManagerBuilder auth) throws Exception { Read more about Active Directory/LDAP authentication with Spring Boot[…]

Spring Boot: run WAR/JAR with specific profiles and/or port

Running from .war/.jar: java -Dspring.profiles.active=dev,other -Dserver.port=3000 -jar spring-app.warjava -Dspring.profiles.active=dev,other -Dserver.port=3000 -jar spring-app.war or java -Dspring-boot.run.profiles=dev,other -Dserver.port=3000 -jar spring-app.warjava -Dspring-boot.run.profiles=dev,other -Dserver.port=3000 -jar spring-app.war Running from Maven project (Spring Boot 2.x): mvn spring-boot:run -Dspring-boot.run.profiles=dev,other -Dspring-boot.run.arguments=–server.port=3000mvn spring-boot:run -Dspring-boot.run.profiles=dev,other -Dspring-boot.run.arguments=–server.port=3000 Spring Profiles

LOGBack: Short console log pattern

# to console without date logging.pattern.console=%-5level [%30.30logger{30}:%4.4line] %msg%n # to file with date logging.pattern.file=%-5level %d{yyyy-MM-dd HH:mm:ss.SSS} [%30.30logger{30}:%4.4line] %msg%n# to console without date logging.pattern.console=%-5level [%30.30logger{30}:%4.4line] %msg%n # to file with date logging.pattern.file=%-5level %d{yyyy-MM-dd HH:mm:ss.SSS} [%30.30logger{30}:%4.4line] %msg%n