Java Community | Help. Code. Learn.

JCH

Java Community | Help. Code. Learn.

With more than 20,000 members, join one of the biggest and most active Java Communities on Discord! ☕

Join

java-help

❓︱qotw-answers

Spring Security Filters

When we need to make our own custom filter chain in spring security and what's actually it's use case ?

Recommendation to store permissions

Hi people i would like advices regarding what's the best way to store permissions without ending with a HUGE table in db and having java to properly handle them. I was thinking on using a maybe numeric value, 1 read, 2 write, 4 delete where a value of 5 means it has delete and read value, a value of 6 read write and deleted and such. But i really don't know if there is any other/recommended way. Regards. :PES3_Wave:...

Spring Security

I want to learn about spring security but I don't know anything about it so can anyone tells me that how much I have to learn it to authenticate my login page and can also add the Google and other outh services in it and can also make my api secure ?

Implementing async file watching

using this doc page: https://docs.oracle.com/javase/tutorial/essential/io/notification.html what would be recommended way of doing it asynchronously? do i just setup some sort of exeuctor or thread?? im not very skilled in parallel stuff...

Hibernate Mapping

I want to map two entities with one to many relationships and want to add the data together. Then how to do it ? Can anyone suggest !

Hibernate is Not Creating Tables

I am trying to create Table Via Hibernate But its not creating anything here is my class https://sourceb.in/TZTKrP7UL4...

Spring JPA Error

I am getting a error like this ->
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'shelfBookController': Unsatisfied dependency expressed through field 'repository': Error creating bean with name 'userRepository' defined in com.ShelfSpace.ShelfSpace.repository.UserRepository defined in @EnableJpaRepositories declared on ShelfSpaceApplication: Not a managed type: class com.ShelfSpace.ShelfSpace.model.UserDto
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:787) ~[spring-beans-6.1.10.jar:6.1.10]
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'shelfBookController': Unsatisfied dependency expressed through field 'repository': Error creating bean with name 'userRepository' defined in com.ShelfSpace.ShelfSpace.repository.UserRepository defined in @EnableJpaRepositories declared on ShelfSpaceApplication: Not a managed type: class com.ShelfSpace.ShelfSpace.model.UserDto
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:787) ~[spring-beans-6.1.10.jar:6.1.10]
When i am trying to ``` @GetMapping("/register") public String registerPage(Model model) {...

Jackson Json overwrites json values when reading from it

having this code snippet and that json, the json have 3 values set to null after running the code snippet and i have no idea why
No description

Spring Boot Error

I am not able to access the /endpoints of my app instead i am getting this error -> ```Whitelabel Error Page This application has no explicit mapping for /error, so you are seeing this as a fallback. ...
No description

Switch from commons-fileupload to commons-fileupload-jakarta-servlet6

I need to change my fileupload-integration to the jakarta6-version. The old code is ``` resp.setHeader("Transfer-Encoding", "chunked"); byte timeout = parseTimeoutParameter(req); int port = parsePortParameter(req); long expLen = Long.valueOf(req.getHeader(HttpHeaders.CONTENT_LENGTH));...

Spring Security

I am Not Able to Access Any Of my Endpoints here is the Config File ```package com.example.firstSpringBoot.config; import java.util.ArrayList; import java.util.List; ...
No description

how to manage two ssl certs in my spring app?

hey guys. i have mTLS in my app. i have jks with two certs in it. cert1 and cert2. my app calls two completely different apis/endpoints: api1/endpoint1 and uses cert1, and api2/endpoint2 and uses cert2. i was wondering do i need to make any changes in my rest template config? bc as i understand, i need to specify which cert to use for which api (or endpoint). but i was told that when mTLS is being initated and my app receives CertificateRequest, spring looks into the keystore, and just...

Spring Security

I dont know why but i am not getting default login page after enabling the @WebSecurity annoation .. ```package secuityConfig; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;...
No description

Spiring bean scope related query

okay so i was just making a mini project where the first page is a login page and when you login successfully youll get a page where you can add items to your cart and also option to display your cart i made a session mapped LoginService class which has a private User attribute so whenever there was a succesful login i was assigning the user attribute of LoginService an object(the first function) and whenever an item was to be added i was adding it to the user attribute of LoginService bean(second method) but different LoginService beans are injected into the first and second method. Why is that so. isnt LoginService SessionMapped??...

how to use two separate SSL certs when my app calls different endpoints?

hey guys. i have a spring application. there are two endpoints that are being called in it (for example endpoint1 and endpoint2). and also there are two security certificates (for example cretificate1 for endpoint1 and certificate2 for endpoint2). i have a problem. how to switch between certificates? because once the application is running, the JKS is already loaded. how to approach this issue? thanks in advance.

jackson json question

suppose i have json array stored inside the file in the projects variable. how can i update it properly without rewriting it?...
No description

couldnt resolve placeholder from the config

hey guys. i have this config: ```yaml bankAccounts: - iban: "LT123" cashRegId: 2...

how to use resource in resourceloader?

hey guys. i have an xml in this dir: src/main/resources/communicationTestRequestBody.xml and i dont know how to specify the dir: ```java ResourceLoader resourceLoader = new DefaultResourceLoader();...

Gradle Translation

What is the gradle equivalent of this?
mvn org.apache.maven.plugins:maven-install-plugin:3.1.2:install-file -Dfile=LocalDependency.jar
mvn install
mvn org.apache.maven.plugins:maven-install-plugin:3.1.2:install-file -Dfile=LocalDependency.jar
mvn install
...