Answer the question
In order to leave comments, you need to log in
Call/create Scala class from Java in SpringBoot Project?
Hello,
I'm building a small web application based on SpringBoot.
But some functions will be
done by another person, and he would like to do everything on Scala + Spark, and so on.
calculation in the form of a String or POJO.
Basically, I now have a working application on SpringBoot, which is completely up to the start on Scala.
Now the issue of developing security has become, and so on. And I understand that I will have to look for other libraries, in any case there will be "dances with tambourines", since I am very poorly familiar with the rock.
As a result, several common questions arose.
Therefore, I decided to do everything in the usual Java and all the necessary calculations in Scala.
1. What problems can I face if I create a Scala-object from Java, for example? ScalaObject sc = new ScalaObject(str); For example, how to handle Exceptions,
etc. .scala
3. Maybe someone has already done similar projects, I will be grateful for the hints of the link and so on ..
Thank you!
Answer the question
In order to leave comments, you need to log in
Scala + Spark is certainly good, but as far as I know (I listened to Evgeny Borisov's report at last year's JPoint ) there are no problems working with Spark from Java. And one more thing does not fit in my head, namely "a small web application" and the use of Scala and Spark for calculations. This is what I mean, maybe you shouldn’t overcomplicate the task at the start? Gather requirements, think about architecture. You can plunge into the "wonderful" world of microservices, then the computing part can be in Scala, Python, and JavaScript.
Personally, I would not bother, and would write everything in Java. Well, if you really want functionality, you can take a closer look at Kotlin .
Eugene In the beginning I want to thank you for a good and detailed answer.
Scala + Spark is certainly good, but as far as I know (I listened to Evgeny Borisov's report at last year's JPoint) there are no problems working with Spark from Java.- I also listened to this report, but I think you will agree that in Java the implementation is not 100% the same as in Scala. For Spark, Scala is the main language, they try to keep the rest up to par. Well, the second point, that part - for the calculations will be done by another person and he wants to learn exactly Scala and not so much in Java.
And one more thing does not fit in my head, namely "a small web application" and the use of Scala and Spark for calculations. This is what I mean, maybe you shouldn’t overcomplicate the task at the start?- that's it, you need to start, so that everyone does at least a little bit of their own, and in the process you can change something ... The main thing is to think over the minimum. ))
Gather requirements, think about architecture. You can plunge into the "wonderful" world of microservices, then the computing part can be in Scala, Python, and JavaScript.- The requirements are collected, as I described the problem - a person wants a rock, but I can’t do the whole web project right away and other libraries and a rock. Thinking architecture in progress. Part of the thought, vott, I'm interested here to better understand. I am familiar with this "beautiful" world, but if you do everything according to "feng shui", then for communication you will need additional JMS, and so on, I do not continue the list, because I understand how much work there is .. If for two people download for a while from With this, we won’t wait for the functionality)))
In Scala, absolutely everything is geared towards SBT and its incremental compilation . If you are using something else (Maven, Gradle) then be prepared for compile time to be an issue.
The second point is that few people use Spring (including Spring Boot) from Scala - not because it's impossible, but because it's stupid. There are solutions in the Scala ecosystem that are both faster and more reliable, and better fit into the language, etc. Accordingly, the result of learning a new language will also not be very good. By the way, about how Spark developers use Scala, read here:
https://www.reddit.com/r/scala/comments/2ze443/a_g...
It would be better to take SBT, Play, MacWire (etc. .d.) - less problems and much more benefits.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question