For devlopment I am using Intellij IDE. I found “File and Code Templates” and “Live Templates” very useful, It is beneficial while doing day-to-day development. It saves some time and be more productive. github link: https://github.com/purab/IntelliJ-IDEA-File-Templates Mostly we work on Rest APIs. So I created the following File Templates Spring ControllerSpring EntitySpring RepositorySpring ServiceSpring Static …
Category Archives: JAVA
intellij configure tomcat server
For configure tomcat in intellij IDE you need to download tomcat server from following URL https://tomcat.apache.org/download-90.cgi Install Smart Tomcat plugin to intellij IDE smart tomcat plugin Go to edit configurations section and configure your project. Steps are given in this video https://www.youtube.com/watch?v=2C8RGyC-dlY tomcat serer
Solved: intellij java: package javax.servlet.http does not exist
While running java web project I got following error. java: package javax.servlet does not exist Two solve you need to add javax.servlet-3.0.jar file in your project or ide while executing code you can download jar from this URL: http://www.java2s.com/Code/Jar/j/Downloadjavaxservlet30jar.htm Solution: File -> Project Structure->Libraries and add javax.servlet-3.0.jar library Detail can found in this video https://www.youtube.com/watch?v=kOrpI-3YHVY …
Continue reading “Solved: intellij java: package javax.servlet.http does not exist”
java mariadb executeQuery right syntax to use near ‘? mapping exception
I was using following code String sql = “select * from user where username=? and password=?”;PreparedStatement ps =connection.prepareStatement(sql);ps.setString(1, username);ps.setString(2, password);ResultSet rs=ps.executeQuery(sql);while (rs.next()) {user= new User();user.setId(rs.getInt(1));user.setName(rs.getString(2));user.setEmail(rs.getString(3));user.setQualification(rs.getString(5));user.setRole(rs.getString(6));} I got following eror: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near …
Continue reading “java mariadb executeQuery right syntax to use near ‘? mapping exception”
SSL certificate integration in Spring boot Project
SSL certificate integration SSL certificate setting applied in application.properties file To generate self signed SSL certificate use following command: cd src/main/resources keytool -genkeypair -alias local_ssl -keyalg RSA -keysize 2048 -storetype PKCS12 -keystore local-ssl.p12 -validity 365 -ext san=dns:localhost Put following code into application.properties file spring.application.name=ssl-certificate server.port=8443 #server.port=8080 server.ssl.enabled: true server.ssl.key-alias: local_ssl server.ssl.key-store: classpath:local-ssl.p12 server.ssl.key-store-type: PKCS12 server.ssl.key-password: …
Continue reading “SSL certificate integration in Spring boot Project”
Solved Error executing DDL “alter table events drop foreign key
While running spring boot application I got following error 2021-10-22 13:38:59.732[0;39m [33m WARN[0;39m [35m700[0;39m [2m—[0;39m [2m[ restartedMain][0;39m [36mo.h.t.s.i.ExceptionHandlerLoggedImpl [0;39m [2m:[0;39m GenerationTarget encountered exception accepting command : Error executing DDL “alter table users_roles add constraint FKt4v0rrweyk393bdgt107vdx0x foreign key (role_id) references role (id)” via JDBC Statement org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL “alter table users_roles add constraint FKt4v0rrweyk393bdgt107vdx0x foreign …
Continue reading “Solved Error executing DDL “alter table events drop foreign key”
Spring and Gradle – adding to the project WebJars Bootstrap
If you wanted to add bootstrap UI CSS and JS files in thymeleaf then you can use following code: <link th:href=”@{/webjars/bootstrap/5.0.0/css/bootstrap.min.css}” rel=”stylesheet” media=”screen” /><script th:src=”@{/webjars/bootstrap/5.0.0/js/bootstrap.min.js}”></script> If those styles are still not loading then refresh project and if you are using spring security then you need to add following code in your extended class of WebSecurityConfigurerAdapter …
Continue reading “Spring and Gradle – adding to the project WebJars Bootstrap”
windows 10 kill port 8080
When I tried to start spring boot application I got the following error Web server failed to start. Port 8080 was already in use. Action: Identify and stop the process that’s listening on port 8080 or configure this application to listen on another port. Solution: I executed following commands for kill 8080 port >netstat -ano …
java error invalid source release 15 in intellij Idea Solved error
While the spring boot project was running project in IntelliJ idea I got the following error: language level is invalid or missing in pom.xml. current project jdk is 15 and this also; java error invalid source release 15 This issue will occur when you have two or more java versions installed in machine. I did …
Continue reading “java error invalid source release 15 in intellij Idea Solved error”
blocked cors localhost:3000 springboot issue
I tried to fetch localhost:8080 spring-boot application and I got the following error in the console. Access to XMLHttpRequest at ‘http://localhost:8080/’ from origin ‘http://localhost:3000’ has been blocked by CORS policy: I did the following changes in SpringSecurityConfig class file: @Override protected void configure(HttpSecurity http) throws Exception { http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and().exceptionHandling() .authenticationEntryPoint(restAuthEntry).and() .authorizeRequests((request) -> request.antMatchers(“/api/v1/auth/login”).permitAll() .antMatchers(HttpMethod.OPTIONS, “/**”).permitAll()) .addFilterBefore(new …
Continue reading “blocked cors localhost:3000 springboot issue”