Tag Archives: spring

AbstractMethodError Spring Security in reqeustMappingHandlerMapping

Questions: When I’m trying to launch the application with spring security enabled I get AbstractMethodError after it launched and when I make requests to my app. The application works fine without spring-security but when I import the security configuration it breaks down. I investigated that it happens because of @EnableWebSecurity which has @Import({ WebSecurityConfiguration.class, SpringWebMvcImportSelector.class… Read More »

Consider defining a bean named 'entityManagerFactory' in your configuration., mssqlserver after upgrade to spring boot 2

Questions: I am trying to upgrade the spring boot 1.5.9 to 2.0.3, and the service failed to start with the following errors: *************************** APPLICATION FAILED TO START *************************** Description: Method mvcConversionService in org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$EnableWebMvcConfiguration required a bean named ‘entityManagerFactory’ that could not be found. Action: Consider defining a bean named ‘entityManagerFactory’ in your configuration. Process finished… Read More »

Order by clause query in Spring MVC with MapSqlParameterSource

Questions: I am trying to a SQL query in Spring MVC 4 with order by clause. But it does not work. I am using MapSQLParameterSource class to define sql parameters. MapSqlParameterSource params = new MapSqlParameterSource(); params.addValue(“lowerLimit”, lowerLimit); params.addValue(“upperLimit”, upperLimit); params.addValue(“filter”, filter.trim()+”%”); params.addValue(“order”, order); String sql = “SELECT * FROM tbl_Subject WHERE subjectName LIKE :filter ORDER… Read More »

Spring : Download file from REST controller

Questions: I work on a Spring project to make a web app so there is a Tomcat server which permit me to lunch my web app. I’ve got 2 functionalities on this web app, the first permit me to upload a file on a Postgresql Database (it’s works correctly). But after that, i want to… Read More »

Docker-compose up springboot + postgres Connection refused

Questions: I create an sample java project with springboot data and postgres. I started to make my docker-compose but i can’t link my database to my application… I have this error web_1 | org.postgresql.util.PSQLException: Connection to localhost:5438 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections. On… Read More »

How to migrate spring DataSource tomcat to hikari properties?

Questions: I have the following tomcat connection pool configuration from spring-boot-1.x. As of spring 2 the default is hikaricp. How can I migrate the following properties to the hikari pendant? I could not find them: spring.datasource.tomcat.test-on-borrow=true spring.datasource.tomcat.initial-size=1 spring.datasource.tomcat.max-idle spring.datasource.tomcat.initial-size spring.datasource.tomcat.max-age spring.datasource.tomcat.test-while-idle spring.datasource.tomcat.test-on-connect spring.datasource.tomcat.test-on-return spring.datasource.tomcat.time-between-eviction-runs-mills spring.datasource.hikari.*? Answers:

Spring ReflectionTestUtils does not set static final field

Questions: I have a static final field like this: class SomeClass { static final String CONST = “oldValue”; } and i’m trying to change that field in test like this: ReflectionTestUtils.setField(SomeClass.class, “CONST”, “newValue”); but it doesn’t work and says java.lang.IllegalStateException: Could not access method: Can not set static final java.lang.String field Answers:

How to route a landing page to a Spring Boot Application?

Questions: I’m trying to add a landing page to a Spring Application that I created so that when the application initially loads the landing page is the first page that is seen. The issue is, I created the landing page after I created the application and so the application loads a login/register page first and… Read More »

AntMatcher in Spring Security

Questions: I’m unable to configure my rules to match the following criteria: GET requests to -> “/logout”, “/user” ,”/oauth2/auth”, “/error**” (Everyone) POST request to -> “/oauth2/token” (Everyone) Every request I make to the endpoints above are validated and authorized when send through GET request (even “/oauth2/token”). POST request are denied. My rules looks like: //… Read More »