Get Started!

So after a while that I haven’t been updating the blog. A lot of things happened in the meantime, but one that I have been working on is a bootstrap/java/spring/mvc  Starter Kit; Some people want to begin writing web applications in Java but they do not know where to start; some of my friends always ask me and It takes a lot of time to explain them, and now that the technologies that I commonly used are far more simple to use, like the newest version of Spring Framework (on which you can develop now “almost” free of XML), or like gradle and his wonders *wink* *wink*. The starter kit is now it is usable, and you can forkit, clone it or download it from github.

I will explain later on all the things I have been adding into the Starter Kit, for the moment I will begin with the Gradle Environment and project setup. Oh! and I forgot to mention this contains websocket support! I got a little help from this repo (he deserves and internet).

So as any gradle project we start with the build.gradle file…

So we use the common imports: java, war, eclipse. And then Tomcat, which was updated recently to support websockets (there are small issues but they are bearable. I defined the port number just because I like 12000;

apply plugin: 'tomcat'

tomcatRun.httpPort=12000

Then the definitions of versions for Spring and Spring Security. This last one is worth to mention that they also upgraded to be “XML Free”.

springVersion="4.0.1.RELEASE"
springSecurityVersion="3.2.0.RELEASE"

And then for the tomcat dependency, the version is very important since the plugin does not work correctly with lower versions, nor the websocket is supported, hence the configuration I used is the next:

    def tomcatVersion = '7.0.52'
    tomcat  "org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}",
    "org.apache.tomcat.embed:tomcat-embed-logging-juli:${tomcatVersion}",
    "org.apache.tomcat.embed:tomcat-embed-websocket:${tomcatVersion}"
    tomcat("org.apache.tomcat.embed:tomcat-embed-jasper:${tomcatVersion}") {
        exclude group: 'org.eclipse.jdt.core.compiler', module: 'ecj'
    }

Then after tomcat dependency definition, the dependencies of the libraries we use. Pretty much selfdescribed, Data Connection, MVC Spring, WebSocket support using Spring Messaging and the Spring WebSocket Library, log4j, the definition of the Servlet 3.1, and junit for testing (even though I did not created tests for it “yet”… I swear I will create tests for it… no really I mean it… ok No probably not).

And that is it for the gradle configuration, after that well gradle project structure is the same

+-src
    +-test
        +-java
        +-resources
    +-main
      +-java
      +-resources
      +-webapp
          +-META-INF
        |-Manifest
      +-WEB-INF
        |- web.xml

And I will go through the initial application setup in another post…

El_avena Off.