I want to create a multi-module (maven) spring MVC application, with modules like:
web
persistance (hibernate)
core (general libs)
models
job-server (queue based jobs)
services (business logic)
Now to use Scala in this project, can I write scala everywhere without any problems?
Or should I use scala for my services module, and java for the web module?
I know hibernate will have to be in java.
Thoughts? Advice?
Are there any issues to look out for? Is this a good idea? Will I have to hack certain parts to glue them together?
Yes, you can use Scala for both your Spring MVC code and your Hibernate classes.
Here is an example of a Spring MVC Controller in Scala taken from one of my projects:
And an example of a Hibernate domain class. Note the use of private Java collection classes for Hibernate adapted by public Scala collection classes for users of the class (helped by Scala’s JavaConversions class).
The only thing I’ve found that I’ve had to use Java for is writing
@Retention(RUNTIME)annotations (for JSR-303 validations).I use Maven and the maven-scala-plugin with mixed Java/Scala projects.