Sunday, November 15, 2015

Consuming a RESTful Web Service Video and Notes

mkdir src/main/java/hello

@JsonIgnoreProperties - any properties not bound in this type should be ignored.

gradle bootRun
or
gradle build
java -jar build/libs/gs-consuming-rest-0.1.0.jar

OR

gradle wrapper
./gradlew bootRun
or
./gradlew build
java -jar build/libs/gs-consuming-rest-0.1.0.jar

OR

mvn spring-boot:run
or
mvn clean package
java -jar target/gs-consuming-rest-0.1.0.jar

output:
2015-11-14 03:20:26.415  INFO 23613 --- [main] hello.Application  : Quote{type='success', value=Value{id=12, quote='@springboot with @springframework is pure productivity! Who said in #java one has to write double the code than in other langs? #newFavLib'}}

Thursday, November 12, 2015

Building Java Projects with Maven Video and Notes

mvn compile
mvn package
mvn install

Greeter.java
package hello;

public class Greeter{
public String sayHello(){
return "Hello world!";
}
}

HelloWorld.java
package hello;

import org.joda.time.LocalTime;

public class HelloWorld{
public static void main(String[] args){
LocalTime currentTime = new LocalTime();
System.out.println("The curent local time is " + currentTime);
Greeter greeter = new Greeter();
System.out.println(greeter.sayHello());
}
}

pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.springframework</groupId>
    <artifactId>gs-maven</artifactId>
    <packaging>jar</packaging>
    <version>0.1.0</version>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>joda-time</groupId>
            <artifactId>joda-time</artifactId>
            <version>2.2</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>2.1</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <transformers>
                                <transformer                                  implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>hello.HelloWorld</mainClass>
                                </transformer>
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

Wednesday, November 4, 2015

Building Java Projects with Gradle Video and Notes

gradle tasks
gradle wrapper
gradlew build
gradlew run
jar tvf build/libs/gs-gradle-0.1.0.jar

HelloWorld.java
package hello;

import org.joda.time.LocalTime;

public class HelloWorld{
public static void main(String[] args){
LocalTime currentTime = new LocalTime();
System.out.println("The current local time is: " + currentTime);

Greeter greeter = new Greeter();
System.out.println(greeter.sayHello());
}
}

Greeter.java
package hello;

public class Greeter{
public String sayHello(){
return "Hello world!";
}
}

//build.gradle file starts
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'application'

mainClassName = 'hello.HelloWorld'

repositories{
mavenCentral()
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

dependencies {
compile "joda-time:joda-time:2.2"
}

jar{
baseName = 'gs-gradle'
version = '0.1.0'
}

task wrapper(type: Wrapper){
gradleVersion = '2.3'
}
//build.gradle file ends

Tutorial Fly YouTube Channel