Tomasm21
JCHJava Community | Help. Code. Learn.
•Created by Tomasm21 on 9/27/2024 in #java-help
Cannot host Spring web app war on Tomcat using Jenkins plugin
13 replies
JCHJava Community | Help. Code. Learn.
•Created by Tomasm21 on 9/23/2024 in #java-help
Jenkins build step doesn't execute as it should.
I try to download my project from GitHub repository using Jenkins and then to build. Later I will join tomcat server and automatically host on localhost or aws.
Currently something is wrong. I have this script:
I call it using
call build-script.bat
in Jenkins step Execute Windows batch command
.
But Instead of executing all the script Jenkins finishes it prematurely:76 replies
JCHJava Community | Help. Code. Learn.
•Created by Tomasm21 on 9/13/2024 in #java-help
I try to write JUnit integration test and to test whether service method works well. It isn't.
This is the service class:
163 replies
JCHJava Community | Help. Code. Learn.
•Created by Tomasm21 on 7/22/2024 in #java-help
Spring app doesn't read environmental variables from .env
I have .env file in my project root folder along with pom.xml. Contents:
and in application properties I use these values:
I even added Dotenv Dependency:
and configured it:
This class should set the system properties using the values from the
Dotenv
bean:
But actually it doesn't work and I get an exception when I launch my application.
I'm on Windows 10.13 replies
JCHJava Community | Help. Code. Learn.
•Created by Tomasm21 on 5/6/2024 in #java-help
Help to define Jsonfactory
@dan1st | Daniel
Can you help me to write
JsonFactory
bean?
I got this error:
The BloggerServiceConfiguration
is:
I try to define the JsonFactory
:
But JacksonFactory
is underlined in red - JacksonFactory cannot be resolved
The com.google.api.client.json.jackson2..
is obsolete.
Now jackson comes from:
But how to use it in bean?169 replies
JCHJava Community | Help. Code. Learn.
•Created by Tomasm21 on 5/2/2024 in #java-help
Cannot start the backup Spring project
I deleted corrupted Spring boot directory. Then to the root of the project I pasted the backup Spring boot directory from backups folder. But everytime I try to launch the app it starts to create
tempDir
in C:\WINDOWS\
:
I don't know what to do. How to fix this?10 replies
JCHJava Community | Help. Code. Learn.
•Created by Tomasm21 on 4/1/2024 in #java-help
Failed to run SB using Eclipse IDE run command using environment variables in application properties
10 replies
JCHJava Community | Help. Code. Learn.
•Created by Tomasm21 on 2/23/2024 in #java-help
Swagger 2 is not launching. Keep getting 401 Unauthorized error
6 replies
JCHJava Community | Help. Code. Learn.
•Created by Tomasm21 on 11/19/2023 in #java-help
Is it correct sql query inside jpa repository interface method annotation?
4 replies
JCHJava Community | Help. Code. Learn.
•Created by Tomasm21 on 5/31/2023 in #java-help
Cannot get inputStream from web url. Why?
I'm trying to create a book with an image in JUnit test using
MockMultipartFile
. But for unknown reasons the stream cannot be taken. Why?
13 replies
JCHJava Community | Help. Code. Learn.
•Created by Tomasm21 on 5/26/2023 in #java-help
Why new entity is saved with null field value when annotation tells that the value cannot be null?
9 replies
JCHJava Community | Help. Code. Learn.
•Created by Tomasm21 on 4/19/2023 in #java-help
Hibernate doesn't save a list of authorities of a user to table as separate rows. It saves only one.
I need help to save several roles of a user to database. Using Spring Boot JPA. User can have many roles. A role belongs to one user. I tried to create three users - an admin, a user and a manager. Admin has admin role, user has user role. Manager has both - admin and user roles.
I have Authority class that has a role. The problem is that for the manager hibernate creates only last role - USER. And I expected that it will have both roles. In database I see that manager has only 1 row. And it should have 2 rows. What am I doing wrong?
User:
Authority:
42 replies
JCHJava Community | Help. Code. Learn.
•Created by Tomasm21 on 4/13/2023 in #java-help
Java Spring Security Cors error
I'm trying to enable cors between browser and server api because website shows cors error. I try to add further bean:
But then I get an error:
How to solve this? Should I remove
config.addAllowedOrigin("*");
line? Or should I ask exact url to my UI: "http://localhost:3000/"
What if this url will be changed in production?9 replies
JCHJava Community | Help. Code. Learn.
•Created by Tomasm21 on 11/21/2022 in #java-help
How do you get a list of entities in JQuery if entity field property has specific column name?
Lets say you have Orders entity:
And in Orders Data Access Object you get the list of orders for that specific user. How jQuery query should look? This way:
or like this:
?
Does column name impact the way how you should access entity property inside jQuery?
5 replies
JCHJava Community | Help. Code. Learn.
•Created by Tomasm21 on 11/17/2022 in #java-help
What is an order in e-commerce application and how to control it. How is it related with user cart?
I'm training to create my first Food ordering from catering establishments application. I created administrator and his ability to add, edit and delete catering establishments - canteens, cafes, bars etc. Also to add various menu types and dishes into it. To edit it and to delete it. I have also created cart for users to add dishes from menus., edit quantity or to removes products from cart.
But now I have to create an order. I kinda know what it is, but I don't know how exactly is it related with other entities. I know that each order should be for each user's cart at that exact time when he presses Checkout or order button. Then in the database there should be an order and all related information about the user and his ordered goods - dishes, quantities, price etc.
What is relation between order and cart. For example my cart entity is this:
Manager or admin should be able to confirm or cancel the order. I think for the order I will use enum with values such as
submitted, approved, withdrawn
47 replies
JCHJava Community | Help. Code. Learn.
•Created by Tomasm21 on 11/8/2022 in #java-help
Question about SecurityContextHolder from Spring Boot Security
Speaking about Spring Boot RestController... - can I extract a username from SecurityContextHolder only once outside of all methods and then use that string username in any methods as a class scope variable or a constant? Or should the username acquiring be only inside any particular method that has @Secured({"..."}) and mapping annotations? Can the SecurityContextHolder be in a service?
13 replies