Stefan Jankovic

Ranch Hand
+ Follow
since Mar 31, 2021
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Stefan Jankovic

Is there any fast way how I can do it? Typing doesn't work, unfortunately.
1 week ago
Can someone tell me how to solve this problem the easiest way?
I have String 202104 that I want to turn into Date. So, it means it would be year 2021, month 4 and day 00.
2 weeks ago
Then what does @Temporal even do? Just formats Date object?
3 weeks ago
So far I used MySQL's DATE data type, which I mapped like:

I hoped that changing temporal's value from DATE to TIME would work. Unfortunately, it throws an exception. What can be done now? Is there an alternative?

P.S. Why I must keep part: new Date();? Shouldn't it be mapped to the current Date if I omit that field from Postman? If I omit it, I get null.
3 weeks ago
Hmmm I don't know. I am using IntelliJ.
1 month ago
I made a simple Java project with the console message "Hello world". Before I created it, I set its JDK to 11.

I wanted to test JDK 16, so I changed it in project structure. After I ran my program, what I get is "cannot determine path to 'tools.jar' library for 16".
Can someone tell me why I can't play around with different JDKs after the program is set up? Does it mean it's stuck forever with JDK 11?
1 month ago
Everyone knows that relational databases contain relations that are "described" with foreign keys. I later can use SQL JOINs to obtain Result Sets from those joins.

But what I noticed is that I can make such JOINs without even specifying foreign key CONSTRAINTs in my tables. Doing "simple" JOIN between some tables (that are now not logically adjacent) should work as well. So, why should I always specify constraints when SQL JOIN commands work just as same? I know I am losing/missing something, I just don't know what.
Thanks for the very good reply. Everything is clear now
2 months ago
I have application.yml file with following properties:

When I run my app, it shows application is running on port 8050.

And then I wanted to "extract" that value using some @Configuration annotated class:

What I get is:

Can someone explain this weird behavior? I have done reading from yml files several times and it worked every single time. Well, except with this case. What am I missing?
2 months ago
Yes, I know how to do that. But for the sake of this example, how do I test those beans using main() method?

I am following one book and I would like to do everything from scratch without making actual requests to my app.
2 months ago
So far, I have used XML file for component-scan of my entire application. Then, to access bean(s) from Spring Container, I would do something like:

But then I learned that I can have class annotated with @ComponentScan that serves the same purpose.

So, instead of writing this in XML file:
, I can do this instead:

But I am stuck now. How do I access beans from Spring Container now? Because component-scan from XML is replaced with @ComponentScan, meaning I can't anymore do:

2 months ago
When validating objects using Validator interface (with supports() and validate() methods) I first make a class that implements Validator and then logically implement those two methods. After that I invoke it inside some controller. Question is related concurrency and thread safety and it is: do I make new instance of Validator each time I am validating something, or I can make Validator instance singleton and simple inject it in my controller? Can something go wrong if I use same instance of Validator for each REST request in controller?
2 months ago
I understand every major OOP principle in Java, so I thought that learning JS would be piece of cake. But then I came across term called prototype in JS which troubles me. Can someone tell me how Java doesn't need prototypes unlike JS? What are prototypes replaced by in Java and how can I picture it from Java's perspective so I can understand it better in JS?
This is from where I am learning spring. But I can't find anything related with reading properties from YML/YAML files. Can someone help me pin point it?

Also, is this the only Spring doc reference out there? Maybe I am missing something else.. Thanks!
4 months ago