Contents
- SUTD-bank Webapp
- Pre-requisites
- Deployment guide
- Step 1. Fork or download the source code from this repository
- Step 2. Import the web application project into Eclipse
- Step 3. Update your MySQL server configurations
- Step 4. Start MySQL server
- Step 5. Generate default MySQL tables
- Step 6. Add a JDBC connector binary to Apache Tomcat server
- Step 7. Deploy your web application from Eclipse (Optional)
- Step 8. Deploy your web application in Apache Tomcat (Optional)
See yet another insignificant programming notes for installation instructions.
Install Eclipse IDE for Java EE Developers (not to be confused with Eclipse IDE for Java Developers). You may choose the Oxygen release or any recent releases.
Make sure that you have selected Eclipse's default JRE to be JDK 1.8 or later (see yet another insignificant programming notes).
See yet another insignificant programming notes for installation instructions.
See yet another insignificant programming notes for installation instructions.
We shall refer to the Apache Tomcat installation directory as <TOMCAT_HOME>
.
See yet another insignificant programming notes for installation instructions. A default MySQL server account with the username root
will be created and you will be prompted to create a password.
Do not forget your password!
MySQL Workbench will be useful for debugging your web application's database.
This guide assumes that you are using Eclipse IDE for Java EE Developers.
Download this repository as a zip file and extract it into your Eclipse workspace.
Alternatively, navigate to your Eclipse workspace using your terminal or command prompt and run the following code to clone the repository into your Eclipse workspace:
$ git clone https://github.com/sunjun-group/bankwebapp.git
We will refer to the project's root directory as <BANKWEBAPP>
.
The project structure is as follows:
+ src/main/java [Java code]
+ src/main/resources [configuration for database and email]
+ database.properties
+ email.properties
+ create.sql [MySQL script to create tables]
- Click on
File --> Import...
- Select
Existing Projects into Workspace
- Select the project's root directory
<BANKWEBAPP>
and clickFinish
Edit <BANKWEBAPP>/src/main/resources/database.properties
and modify:
jdbc.password
-- replace with the password of yourroot
MySQL server account
See yet another insignificant programming notes for instructions.
Right-click on <BANKWEBAPP>/src/test/java/sutdbank/DbCreator.java
and select Run As --> Java Application
.
This step creates/overwrites the default schema bankwebapp
.
Copy <BANKWEBAPP>/libs/mysql-connector-java-5.1.35.jar
into <TOMCAT_HOME>/lib
.
In this step, we will guide you to attach Apache Tomcat to Eclipse so that you can run and debug your web application from within Eclipse. If you do not wish to do so, skip ahead to Step 8.
Follow Steps 3 to 5 of this online tutorial.
Do not start your web server yet!
After the previous step, you should see a new project folder named Servers
in your Eclipse workspace.
Open Servers/Tomcat vX.X Server at localhost-config/server.xml
(where vX.X
refers to your Apache Tomcat version, e.g., v8.5
) and add the following lines between the <Engine> ... </Engine>
tags:
<Realm
className="org.apache.catalina.realm.JDBCRealm"
driverName="org.gjt.mm.mysql.Driver"
connectionURL="jdbc:mysql://localhost:3306/bankwebapp"
connectionName="root"
connectionPassword="INSERT_YOUR_PASSWORD_HERE"
userTable="user"
userNameCol="user_name"
userCredCol="password"
userRoleTable="user_role"
roleNameCol="role"
/>
Replace the connectionPassword
field with the password of your root
MySQL server account.
Right-click on your web application project in Eclipse and select Run As --> Run on server
.
Navigate your web browser to http://localhost:8080/sutdbank.
You should be able to log in with the default account staff_1/123456
.
Edit <TOMCAT_HOME>/conf/server.xml
and add the following lines between the <Engine> ... </Engine>
tags:
<Realm
className="org.apache.catalina.realm.JDBCRealm"
driverName="org.gjt.mm.mysql.Driver"
connectionURL="jdbc:mysql://localhost:3306/bankwebapp"
connectionName="root"
connectionPassword="INSERT_YOUR_PASSWORD_HERE"
userTable="user"
userNameCol="user_name"
userCredCol="password"
userRoleTable="user_role"
roleNameCol="role"
/>
Replace the connectionPassword
field with the password of your root
MySQL server account.
Delete (if it exists) the folder <TOMCAT_HOME>/webapps/bankwebapp/
.
Right-click on your web application project in Eclipse and select Export...
. Select the WAR file
wizard and:
- Give your web project the title
bankwebapp
. - Select the destination to be
<TOMCAT_HOME>/webapps
. - Un-check the box for
Optimize for a specific server runtime
. - Check the box for
Overwrite existing file
.
This creates the file <TOMCAT_HOME>/webapps/bankwebapp.war
.
Start Apache Tomcat (see instructions) and navigate your web browser to http://localhost:8080/sutdbank.
You should be able to log in with the default account staff_1/123456
.