Translate

Показ дописів із міткою ProjectFromScratch. Показати всі дописи
Показ дописів із міткою ProjectFromScratch. Показати всі дописи

вівторок, 28 квітня 2015 р.

#ProjectFromScratch: SpringBoot - Part2


Hence I decided to create web application then there are two good options for quick start  SpringBoot or Spark
Spark is much simpler but SpringBoot brings Spring - I would say Spring is musthave framework nowdays so that my choice is SpringBoot. 
Following GettingStarted doc I'm creating two classes in web module: config called Application.java and our hello world controller HelloController.java
Usually I create package config for configs and package controller for controllers.

Except created classes we need add required SpringBoot dependency

Add to parent pom dependency management section in following way
 
 <properties>
  <spring.boot-version>1.2.3.RELEASE</spring.boot-version>
 </properties>
 
 <dependencymanagement>
  <dependencies>
   <dependency>
    <groupid>org.springframework.boot</groupid>
    <artifactid>spring-boot-starter-web</artifactid>
    <version>${spring.boot-version}</version>
   </dependency>
  </dependencies>
 </dependencymanagement>
and add to pom.xml in web module dependency itself
 
 <dependencies>
  <dependency>
   <groupid>org.springframework.boot</groupid>
   <artifactid>spring-boot-starter-web</artifactid>
  </dependency>
 </dependencies>
Now you can check if source is compilable with command mvn clean compile and run main on Application.java When you run main, embedded tomcat will start and listen port 8080. Check it with calling url http://localhost:8080

#ProjectFromScratch: Multi module project - Part1


I will try creating new project from scratch step-by-step and write down all steps
If you see better approach or just easier way - please leave comment and I will modify article. Also you can suggest technologies and configurations for that new project
It allows all of us  to gain interesting collective experince

So lets start

Step1: Creating multimodule project with maven
Maven is still most popular build system that's why maven, but if anybody provides code for gradle I will add it to post also
 
//create parent
mvn archetype:generate -DarchetypeGroupId=org.codehaus.mojo.archetypes -DarchetypeArtifactId=pom-root -DarchetypeVersion=RELEASE
go inside parent folder and create child modules
 
//first module
mvn archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=RELEASE
//create one more module
mvn archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=RELEASE


I created two modules core for common things and web