Old Version
New Upgrade ( what's new)
- Hibernate configuration added( database and tables automatically create when run the project)
- Service classes provide reusable services throughout project
- dao classes interact with database
- bug fixed ( product image, security , etc..)
- support in both eclipse & intellij ide
- overall redesign entire code that help reusability.
- disclaimer: currently working on this branch so there may be some bug related to endpoint, and working on cart logic.
Quickstart
- Clone the repository
- Open the project in your IDE: IntelliJ IDEA (recommended) or Eclipse
- If you are using IntelliJ IDEA, make sure the IDE recognizes the project as a Spring Boot project. Also, you must change the working directory of the project so that the views (the actual web pages to be shown) are found by Spring Boot (check out Web Directories IntelliJ IDEA.
- Make sure you are in the
JtProject
directory
- Configure the database connection in
application.properties
file (check the Database section below for more info)
- Run the project (by running the
main
method in JtSpringProjectApplication.java
)
- Open http://localhost:8080/ in your browser!
- If you ran the
basedata.sql
script on the database, you can log in with the following credentials as admin; otherwise you'll have to manually create an admin user in the database:
- Username:
admin
- Password:
123
- Log in as a normal user:
- Username:
lisa
- Password:
765
Database
MySQL or MariaDB can be used as the database for this project. The database connection can be configured in the application.properties
file, with the appropriate values for the following properties:
db.url=jdbc:mysql://[ip address of db]:[port of db]/ecommjava?createDatabaseIfNotExist=true
db.username=[username]
db.password=[password, if any]
Having done that, you must create some base data in the database. You can do that by running the basedata.sql
script on the database. Check out Google for how to do that, because it depends on what tool you are using to access said database.
Web Directories
The views are located in src/main/webapp/views
, but for some reason, Spring Boot doesn't recognize that directory. To remedy this, you must change the working directory of the project in your IDE. If you're using IntelliJ IDEA, follow these steps:
- Click on the "Edit Configurations..." button in the top right corner of the IDE
- Click on the
JtSpringProjectApplication
configuration
- Change the "Working directory" option (if not present, click on "Modify Options" and select from the list) to the
$MODULE_WORKING_DIR$
macro
- Click "Apply" and "OK"
When you run the project, the views should be found by Spring Boot and you should see a login page in http://localhost:8080/ (if not logged in previously)!
Workflow
View
- receive data from controller and show with frontend.
Endpoints
Spring Boot
For any information about Spring Boot, here are some useful links!
Reference Documentation
For further reference, please consider the following sections:
Guides
The following guides illustrate how to use some features concretely:
Preview
Link
- π¬πΌππππ―π² π½πΏπΌπ·π²π°π ππΆπ±π²πΌ πͺπΌπΏπΈπΆπ»π΄ ππ²πΊπΌ + πππ²π½ π―π πππ²π½ π²π
π²π°πππΆπΌπ» πΉπΆπ»πΈ ( old version )::--- click here
Issue and Solution
- A line of code in the AdminController file was generating an error while a PreparedStatement was being executed by execute()
-method. Simply changing that to executeQuery() resolved the issue.
Running with maven for test:
folowing changes have been made to pom.xml:
Instructions:
firstly update your Maven project to apply the changes.
"mvn clean install"
Run this command it will update your maven project.
To run all tests, use the following Maven command:
"mvn test"
To run specific tests, use the -Dtest parameter with the test class or method name:
mvn test -Dtest=TestClass
Replace TestClass with the actual name of the class
Deliverable 5(Running tests)
- Open github.
- Select Actions
- Select configure Jave With Maven
- It will display a screen
- Then select Commit changes
- Go to Intellij
- There will be a "M" symbol on the right
- Press that
- Then select the "Execute Maven Goal"
- It will execute the tests.
- Screen shots have been attached