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 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
...

better ways to load xml as a string?

hey guys. i want to load xml as a string. im doing it this way:
String requestBodyTemplate = new String(Files.readAllBytes(Paths.get("src/main/resources/accountStatementRequestBodyTemplate.xml")));
String requestBodyTemplate = new String(Files.readAllBytes(Paths.get("src/main/resources/accountStatementRequestBodyTemplate.xml")));
and some people on the internet told me there are better ways, but they didnt explain to me. can smb help me out? thanks...

Java Rest API

Can Anyone Explain is it really necessary to make a Rest Api while Storing the user's in the db from registering page ? And when do we actually use a Rest Api in our web application ?

Force install dependency.

I have a maven project with a dependency in the pom: ```xml <dependency> <groupId>tld.domain1</groupId>...

Update Error In Spring MVC

I am Trying to update the user But i found the 405 error like this https://sourceb.in/k8YQbPRuTj why i am getting this Please Help...

Spring JDBC

I am Getting a error like this https://sourceb.in/IQyZlhnarV when i am trying to retrive the id from the table Can Someone Help please...

onMouseClicked event doesnt do anything

<Pane onMouseClicked="#selectPath" style="-fx-border-color: red" AnchorPane.topAnchor="4" AnchorPane.rightAnchor="4" AnchorPane.bottomAnchor="4">
<JetBrainsImage pickOnBounds="true" icon="AllIcons.Expui.General.Open" />
</Pane>
<Pane onMouseClicked="#selectPath" style="-fx-border-color: red" AnchorPane.topAnchor="4" AnchorPane.rightAnchor="4" AnchorPane.bottomAnchor="4">
<JetBrainsImage pickOnBounds="true" icon="AllIcons.Expui.General.Open" />
</Pane>
...

Gradle shade not shading in one operating system, but does in another

I made a docker container meant to build all my paper plugins (minecraft server). The problem is that by somre reason, it does not shade what is otherwise being shade when I run the same command in my OS (windows) Does anyone have a clue what would be the case? I'm quite new to gradle, so that might be the cause. Here's part of the build script: ```kts shadowJar {...