Skip to content
This repository was archived by the owner on Jun 2, 2023. It is now read-only.

Springboot jdbc #55

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 48 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,56 @@ Inside the application project there is a application.servlet package containing
For the complete feature documentation, see the <a href="http://www.ibm.com/support/knowledgecenter/SSAW57_8.5.5/com.ibm.websphere.wlp.nd.multiplatform.doc/ae/rwlp_feat.html%23rwlp_feat__servlet-3.1">servlet-3.1</a> feature description in IBM Knowledge Center.

## Spring Boot with Spring MVC
This provides you with a SpringBoot application that will run on WebSphere Liberty.

Inside the application project there is a application.springboot.web package containing two classes:
* SpringBootLibertyApplication</code>: The entry point for the SpringBoot application.
* LibertyHelloController</code>: A Spring MVC endpoint which you can access at /springbootweb.
This project demonstrate a "hello world" web site with Spring technology and run on IBM WebSphere Liberty Server
Learn more about IBM WebSphere Liberty, visit <a href="https://developer.ibm.com/wasdev/">https://developer.ibm.com/wasdev/</a>

Inside the application project containing two classes:
* application.springboot.Application</code>: The entry point for the SpringBoot application.
* application.springboot.web.LibertyHelloController</code>: A Spring MVC endpoint which you can access at /springbootweb.

Inside the wlpcfg project there is the <code>it.springboot.web.HelloControllerTest</code> that will test the Spring MVC endpoint to ensure it is working.
For the complete feature documentation, see the <a href="http://spring.io/guides/gs/serving-web-content">Serving Web Content with Spring MVC</a>

## Spring Boot with Jersey
This project demonstrate creating a "hello world" RESTful web service with Spring technology and run on IBM WebSphere Liberty Server
Learn more about IBM WebSphere Liberty, visit <a href="https://developer.ibm.com/wasdev/">https://developer.ibm.com/wasdev/</a>


Inside the application project containing 3 classes:
* application.springboot.Application</code>: The entry point for the SpringBoot application.
* application.springboot.jersey.Endpoint</code>: A Jersey endpoint which you can access at /springbootjersey.
* application.springboot.jersey.JerseyConfig</code>: Jersey configuration class.

Inside the wlpcfg project there is the <code>it.springboot.jersey.SampleJerseyApplicationTests</code> that will test the Jersey endpoint to ensure it is working.

For the complete feature documentation, see the <a href="http://spring.io/guides/gs/rest-service/">Building a RESTful Web Service</a>

## Spring Boot with Security
This project demonstrate creating a simple web application with resources that are protected by Spring Security and run on IBM WebSphere Liberty Server
Learn more about IBM WebSphere Liberty, visit <a href="https://developer.ibm.com/wasdev/">https://developer.ibm.com/wasdev/</a>


Inside the application project containing 3 classes:
* application.springboot.Application</code>: The entry point for the SpringBoot application.
* application.springboot.securityMvcConfig</code>: Map each uri to static html resources
* application.springboot.security.WebSecurityConfig</code>: Seucirty configuration for Springboot application

Inside the wlpcfg project there is the <code>it.springboot.security.HelloControllerTest</code> that will test the /springbootsecurity endpoint to ensure it is working.

For the complete feature documentation, see the <a href="http://spring.io/guides/gs/securing-web/">Securing a Web Application</a>

## Spring Boot with JDBC
This project demonstrate how to accessing relational data with Spring technology and run on IBM WebSphere Liberty Server
Learn more about IBM WebSphere Liberty, visit <a href="https://developer.ibm.com/wasdev/">https://developer.ibm.com/wasdev/</a>

Inside the application project containing 3 classes:
* application.springboot.Application</code>: The entry point for the SpringBoot application.
* application.springboot.jdbc.Customer</code>: POJO class for DB table
* application.springboot.jdbc.JDBCController</code>: A Springboot JDBC endpoint which implements the JDBC DB access

Inside the wlpcfg project there is the <code>it.springboot.jdbc.HelloControllerTest</code> that will test the /springbootjdbc endpoint to ensure it is working.

For the complete feature documentation, see the <a href="http://spring.io/guides/gs/relational-data-access/">Accessing Relational Data using JDBC with Spring</a>

## Websockets
This provides you with the websocket-1.1 feature.
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ allprojects {
mavenCentral()
}
dependencies {
classpath 'net.wasdev.wlp.gradle.plugins:liberty-gradle-plugin:1.1-SNAPSHOT'
classpath 'net.wasdev.wlp.gradle.plugins:liberty-gradle-plugin:1.0'
classpath files('gradle/wlp-anttasks.jar')
}
}
Expand Down
2 changes: 1 addition & 1 deletion liberty-starter-application/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ liberty {
}

clean.dependsOn(':liberty-starter-wlpcfg:cleanServer')
war.dependsOn(':liberty-filter-application:publishWar', ':starter-microservice-test:publishTestWar', ':starter-microservice-web:publishWar', ':starter-microservice-persistence:publishWar', ':starter-microservice-rest:publishWar', ':starter-microservice-websocket:publishWar', ':starter-microservice-springboot-web:publishWar', ':starter-microservice-watsonsdk:publishWar', 'compressSkeletonBuildImage', 'copySpecialFiles', 'createSwaggerJSON')
war.dependsOn(':liberty-filter-application:publishWar', ':starter-microservice-test:publishTestWar', ':starter-microservice-web:publishWar', ':starter-microservice-persistence:publishWar', ':starter-microservice-rest:publishWar', ':starter-microservice-websocket:publishWar', ':starter-microservice-springboot-web:publishWar', ':starter-microservice-springboot-jersey:publishWar', ':starter-microservice-springboot-security:publishWar',':starter-microservice-springboot-jdbc:publishWar', ':starter-microservice-watsonsdk:publishWar', 'compressSkeletonBuildImage', 'copySpecialFiles', 'createSwaggerJSON')
installFeature.dependsOn('installLiberty')
libertyStart.dependsOn('installFeature', 'addServerEnv', 'publishWar')
fvt.dependsOn('libertyStart', 'testClasses')
Expand Down
28 changes: 23 additions & 5 deletions liberty-starter-application/src/main/resources/services.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,51 @@
{
"id" : "rest",
"name" : "REST",
"description" : "JAX-RS implementation",
"description" : "REST technology allows to create a simple JAX-RS application by using Liberty jaxrs-2.0 feature. \nNotice that REST technology cannot co-exist with Spring Boot with Jersey technology.",
"endpoint" : "/rest"
},
{
"id" : "websocket",
"name" : "Web Sockets",
"description" : "WebSocket implementation",
"description" : "Web Sockets technology allows to create a simple WebSocket application by using Liberty websocket-1.1 feature.",
"endpoint" : "/websocket"
},
{
"id" : "persistence",
"name" : "Persistence",
"description" : "JPA data persistence",
"description" : "Persistence technology allows to create a simple JPA data persistence application by using Liberty jpa-2.1 feature.",
"endpoint" : "/persistence"
},
{
"id": "web",
"name" : "Servlet",
"description": "Servlet 3.1",
"description": "Servlet technology allows to create a simple Servlet 3.1 application by using Liberty servlet-3.1 feature.",
"endpoint" : "/web"
},
{
"id": "springbootweb",
"name": "Spring Boot with Spring MVC",
"description": "Spring Boot with Spring MVC",
"description": "Spring Boot with Spring MVC technology allows to create a hello world web application with SpringBoot MVC.",
"endpoint" : "/springbootweb"
},
{
"id": "springbootjersey",
"name": "Spring Boot with Jersey",
"description": "Spring Boot with Jersey technology allows to create a JAX-RS application with SpringBoot Jersey support. \nNotice that Spring Boot with Jersey technology cannot co-exist with REST technology.",
"endpoint" : "/springbootjersey"
},
{
"id": "springbootsecurity",
"name": "Spring Boot with Security",
"description": "Spring Boot with Security technology allows to create a simple web application with resources that are protected by Spring Security.",
"endpoint" : "/springbootsecurity"
},
{
"id": "springbootjdbc",
"name": "Spring Boot with JDBC",
"description": "Spring Boot with JDBC technology allows to create a simple Derby DB and do some SQL operation on it.",
"endpoint" : "/springbootjdbc"
},
{
"id": "watsonsdk",
"name": "Watson SDK",
Expand Down
15 changes: 15 additions & 0 deletions liberty-starter-application/src/main/webapp/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,21 @@ body {
padding-bottom: 8px;
}

#step1TechnologiesContainer .step1TechnologyDisabled {
height: 80px;
width: 297px;
padding-left: 26px;
color: #CCCCCC;
font-size: 18px;
border: solid 1px #BEBEBE;
line-height: 80px;
display: inline-block;
margin-right: 40px;
text-decoration: none;
margin-bottom: 34px;
position: relative;
}

#step1TechnologiesContainer .step1Technology {
height: 80px;
width: 297px;
Expand Down
36 changes: 35 additions & 1 deletion liberty-starter-application/src/main/webapp/js/logic.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ $(document).ready(function() {
step1TechnologiesContainer.empty();
for(var i = 0; i < technologies.length; i++) {
var technology = technologies[i];
var technologyTag = $("<a href=\"#\" class=\"step1Technology\" data-technologyname=\""+ technology.name +"\" data-technologyid=\"" + technology.id + "\">" + technology.name + "</a>");
var technologyTag = $("<a href=\"#\" class=\"step1Technology\" data-technologyname=\""+ technology.name +"\" data-technologyid=\"" + technology.id + "\" title=\"" + technology.description + "\">" + technology.name + "</a>");
technologyTag.append('<span class="state-checkmark"></span>');
step1TechnologiesContainer.append(technologyTag);
}
Expand Down Expand Up @@ -108,14 +108,48 @@ $(document).ready(function() {
var updateStep1Summary = function() {
var selectedTechnologies = $("#step1TechnologiesContainer .step1Technology.selected");
var selectedTechnologiesText = "";
var restSelected = false;
var springbootjerseySelected = false;
for(var i = 0; i < selectedTechnologies.size(); i++) {
selectedTechnologiesText += selectedTechnologies.get(i).dataset.technologyname;
if(i + 1 < selectedTechnologies.size()) {
selectedTechnologiesText += ", ";
}

if(selectedTechnologies.get(i).dataset.technologyid == "rest"){
restSelected = true;
}
if(selectedTechnologies.get(i).dataset.technologyid == "springbootjersey"){
springbootjerseySelected = true;
}
}
$("#navigationTop1 .variableContent").text(selectedTechnologiesText);

updateStep1Conflict(restSelected, "springbootjersey");
updateStep1Conflict(springbootjerseySelected, "rest");
};

var updateStep1Conflict = function(selected, id) {
if(selected){
var enabledTechnologies = $("#step1TechnologiesContainer .step1Technology");
for(var i = 0; i < enabledTechnologies.size(); i++) {
var technology = enabledTechnologies[i];
if(technology.dataset.technologyid == id){
technology.className = "step1TechnologyDisabled";
break;
}
}
} else {
var disabledTechnologies = $("#step1TechnologiesContainer .step1TechnologyDisabled");
for(var i = 0; i < disabledTechnologies.size(); i++) {
var technology = disabledTechnologies[i];
if(technology.dataset.technologyid == id){
technology.className = "step1Technology";
break;
}
}
}
};

var refreshSectionVisibility = function() {
var currentlyVisibleSections = $(".step:not(.hidden)").size();
Expand Down
1 change: 0 additions & 1 deletion liberty-starter-wlpcfg/servers/StarterServer/.gitignore

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
/ltpa.keys
/key.jks
/key.jks
4 changes: 4 additions & 0 deletions liberty-starter-wlpcfg/servers/StarterServer/server.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,8 @@
<application location="starter-microservice-watsonsdk.war" id="watsonsdk" context-root="/watsonsdk"></application>
<application location="starter-microservice-websocket.war" id="websocket" context-root="/websocket"></application>
<application location="starter-microservice-springboot-web.war" id="springbootweb" context-root="/springbootweb"></application>
<application location="starter-microservice-springboot-jersey.war" id="springbootjersey" context-root="/springbootjersey"></application>
<application location="starter-microservice-springboot-security.war" id="springbootsecurity" context-root="/springbootsecurity"></application>
<application location="starter-microservice-springboot-jdbc.war" id="springbootjdbc" context-root="/springbootjdbc"></application>

</server>
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ include 'services:webservice'
*/

rootProject.name = 'LibertyUserExperience'
include 'liberty-starter-wlpcfg', 'liberty-filter-application', 'liberty-starter-application', 'starter-microservice-test', 'starter-microservice-web', 'starter-microservice-persistence', 'starter-microservice-rest', 'starter-microservice-websocket', 'starter-microservice-watsonsdk', 'starter-microservice-springboot-web', 'liberty-starter-model', 'liberty-starter-common'
include 'liberty-starter-wlpcfg', 'liberty-filter-application', 'liberty-starter-application', 'starter-microservice-test', 'starter-microservice-web', 'starter-microservice-persistence', 'starter-microservice-rest', 'starter-microservice-websocket', 'starter-microservice-watsonsdk', 'starter-microservice-springboot-web', 'starter-microservice-springboot-jersey', 'starter-microservice-springboot-security','starter-microservice-springboot-jdbc', 'liberty-starter-model', 'liberty-starter-common'
6 changes: 6 additions & 0 deletions starter-microservice-springboot-jdbc/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/target
/build
/.settings
/.classpath
/.project
/bin
44 changes: 44 additions & 0 deletions starter-microservice-springboot-jdbc/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright (c) 2016 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

apply from: '../common-java.gradle'
apply from: '../common-war.gradle'

import com.ibm.liberty.starter.gradle.MavenTask
import com.ibm.liberty.starter.gradle.FvtTask

dependencies {
providedCompile group:'javax.ws.rs', name:'javax.ws.rs-api', version: '2.0'
providedCompile group:'javax.json', name:'javax.json-api', version:'1.0'
}

buildutils {
contextRoot = '/springbootjdbc'
}

task installAllPOMs(type: MavenTask) {
id 'springbootjdbc'
hasProvided true
hasRuntime true
hasCompile true
}

task fvt(type: FvtTask) {
id 'starter-microservice-springboot-jdbc'
finalizedBy libertyStop
}

apply from: '../tech-type-task-graph.gradle'
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>net.wasdev.wlp.starters.springbootjdbc</groupId>
<artifactId>compile-pom</artifactId>
<version>0.0.1</version>

<name>compile-pom</name>

<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>https://raw.github.com/WASdev/tool.artisan.core/master/LICENSE</url>
<distribution>repo</distribution>
</license>
</licenses>

<scm>
<connection>scm:git:[email protected]:WASdev/tool.artisan.core.git</connection>
<developerConnection>scm:[email protected]:WASdev/tool.artisan.core.git</developerConnection>
<url>[email protected]:WASdev/tool.artisan.core.git</url>
</scm>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>1.3.5.RELEASE</version>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>4.2.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>10.12.1.1</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>net.wasdev.wlp.starters.springbootjdbc</groupId>
<artifactId>provided-pom</artifactId>
<version>0.0.1</version>

<name>provided-pom</name>

<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>https://raw.github.com/WASdev/tool.artisan.core/master/LICENSE</url>
<distribution>repo</distribution>
</license>
</licenses>

<scm>
<connection>scm:git:[email protected]:WASdev/tool.artisan.core.git</connection>
<developerConnection>scm:[email protected]:WASdev/tool.artisan.core.git</developerConnection>
<url>[email protected]:WASdev/tool.artisan.core.git</url>
</scm>

<repositories>
<repository>
<id>ibm-maven-repo</id>
<name>ibm-maven-repo</name>
<url>https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/wasdev/maven/repository/</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>com.ibm.websphere.appserver.api</groupId>
<artifactId>com.ibm.websphere.appserver.api.servlet</artifactId>
<version>1.0.10</version>
</dependency>
</dependencies>

</project>
Loading