must Janik

Ranch Hand
+ Follow
since Jul 04, 2018
Cows and Likes
Cows
Total received
1
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
42
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by must Janik

I have byte array which was converted from zip file. I would like to check in the test whether its files contains proper content. So for example zip consists of 2 text files. First file contains "HEY" word, and the sceond "HEY2". I would like to after reconverting whether everything is all right.

I have made something like this:



and it prints:

Entry: 1.txt len 5 added 03/16/21
Entry: 2.txt len 6 added 03/16/21

how can I go deeper inside every file?

7 months ago
God.... You were right Tim.
I logged into manager and I get:
stara_war_exploded as a path so I went into: stara_war_exploded/sayHello and it works...

Couple of hours wasted just for this..
Thanks a lot guys for help!
10 months ago
None of them works which is werid as...
10 months ago
So I added TomcatServer in Configurations of Intellij and before lunch I have appname:war exploded artifact. That's how I'm deploying war on tomcat.
Full logs after running app (deploying in tomcat)


10 months ago
Because I'm comparing app written in Spring Boot and in Spring 3 + jdk 7 for my engineering thesis.

I'm building war. I'm deploying it like this https://bykowski.pl/wdrazanie-aplikacji-spring-na-tomcat/ (it is on polish, but you can conclude from screens how I do it.
10 months ago
The problem was that webapp director was not under src/main.
In logs right now I get:



so I moved forward, but still getting 404 on stara/sayHello or /sayHello

I also added
<dependency>
           <groupId>org.springframework</groupId>
           <artifactId>spring-webmvc</artifactId>
           <version>3.0.7.RELEASE</version>
       </dependency>
dependency to pom.xml
10 months ago
I'm trying to write Spring application in Spring 3.0.x (yes I want that version). Made a really simple method that returns String.



After calling http://localhost:8080/sayHello I'm getting 404 don't know why.



I'm using Tomcat 8.5.60.

My pom.xml



web.xml



DispartcherServlet-context.xml



Could you tell me what I'm doing wrong to make this Controller work?

10 months ago
I tried to create dynamic query using JPA specification, but I'm not sure whether I understood the JPA specification properly. I was using https://www.baeldung.com/spring-data-criteria-queries to write the code. The case is, I got some paramters that are optionals, so first I've written all etc alone. like this (from above site):



while scrolling down the site I could read about JPA specifiaction and it looked much more better, because within each parameters I got next if using above solution.

Using JPA specification the code looks like this for now:



As you can see code looks much more better, I got rid of boiler plate, but the problem is, just those advertisements are returned that meet all requirements so it has category/city/proper title.

If I got



and if I put only Warsaw I want it to be returned, if I put only random (as title) I want it to be returned etc etc, for now if I put Warsaw, random (as title), MUSIC Could you tell me how to do it?


PS: The code  I write is kotlin, but it is very similiar to java so you can propose solution in java if you want.
Thanks a lot for help!

//edit

I changed to

   

and it works, but the question is, how to make to return all the advertisements if no parameters where passed.
11 months ago
To be clear.I want to rewrite application which is written in Spring Boot . I will have 2 application which are the same, but written in two different technologies. It is for my engineering thesis
11 months ago
Hi guys. I have a question regarding spring 2.5 (with java 6). I would like to rewrite web application based on REST which is written in newest version of Spring Boot.
The question is... is it even possible? I mean, I do not want to create any front (returning jsp files), just want to create backend.

Some sample from controller I want to rewrite:



As you can see I just return response in JSON. That's all I want. I read that I need some RestTemplate or something, but it is available since Spring 3.0, so I would need some custom mapper to return json, but it is not that hard I think.
Could you tell me whether is it possible to do it? All tutorials are about returning jsp files which I do not want.
Some sample of service/controller would be extremely useful for me if possible.
Thanks.
11 months ago
Thanks a lot @Stephan! I think I know already everything that I wanted to know.
1 year ago
Hi, I’m going to start writing my application for athletes based on Spring 2.5.6 and Java 6 (as I’ve read that Java 7 is less compatibile with this Spring version). I’ve couple of questions as I’m not familiar with such an old versions. (I need to write it for my Engineer’s Thesis – comparing app written in old version of Spring and in newest version of Sping Boot)  

1. I know already I need web.xml, but do I need servlets  to handle http requests or there is some other common way to do it? I won’t have any front sides (like jsp files) – just backend.
I mean, I want to build the most common app based on Spring 2.5 and java 6 and to do it I need these two things to do any request, right?

2. What about declaring beans in these versions. Do I need to do it in xml like <bean>….</bean> or I can annotate class with for example @Component (as @Service propably does not exist in this version). Which way should I go? I would like the differences to be most visible - beetwen spring boot and old spring, so declaring beans in xml would be fine (as in SpringBoot I have annotation like @Service, @Repository etc) -  but it’s hard to explain in my Engineer's Thesis why I’ve chosen for example declaring beans in xml when I could do it easily with annotations.

Do you have any simple crud examples of projects written in these versions?
1 year ago

Himai Minh wrote:Hi, Must,
I think you may need a CustomAdvertisementRepository interface and its implementation:






Your service or controller can do this:

In your pom, put java persistence dependency



yee, I have made with the same solution earlier. Thanks anyway, will be for next people!
1 year ago
That's why I wanted to use Example, but nevermind will check criteria out.
1 year ago

Dave Tolls wrote:Define a method for your repository which takes all the searchable parameters.
You'll then need to add an implementation, inside which use a CriteriaBuilder, adding criteria for each parameter that is supplied.

Something along those lines.

https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#repositories.custom-implementations
https://www.baeldung.com/spring-data-jpa-query (section 9.2)



Ye, I've heared about that but I thought that it's much longer solution than that I had. I cannot use Example right here?
1 year ago