Environment: JDK 1.8.0_72, TomCat 8.0, IDEA 15.0.3
Technologies: Spring MVC 4.2, Spring Security 3.2.5, Spring WebFlow 2.3.3, Hibernate 4.0.1, H2 database 1.4.191, Twitter Bootstrap 3.3.6, JQuery 1.12.0
I'm working on Ubuntu 14.04 Linux LTS
http://getbootstrap.com/examples/carousel/
IDEA:
New Project --> Maven --> Create from archetype --> Next
GroupId: com.mywebsite
ArticactId: emusicstore
Next
Project name: eMusicStore
Finish
ProjectName --> right click
Add framework support --> Spring --> Spring MVC --> Finish
mkdir src/main/webapp
mv WEB-INF src/main/webapp
File --> Project Structure --> Facets
Web --> Update: Deployment Descriptors and Web Resource Directories.
Spring --> Remove duplicate Application Context
File --> Project Structure --> Artifacts
Select Spring and Spring MVC --> Put into WEB-INF/lib
File --> Project Structure --> Artifacts
Select Maven:jstl and Maven:Taglibs --> Put into WEB-INF/lib
http://localhost:8080/productList/
http://localhost:8080/productList/viewProduct
http://localhost:8080/productList/viewProduct/P121
Theory
http://h2database.com/html/main.html
$ cd /mnt/dsk0/downloads/h2/bin
$ chmod +x ./h2.sh
$ ./h2.sh
or
$ java -jar h2-1.3.176.jar
Connect
http://localhost:8080/productList/
Add next records to DataBase:
ProductId: 1
ProductCategory: Instrument
ProductCondition: New
ProductDescription: Ihis is a description
ProductManufacturer: Manu1
ProductName: Guitar1
ProductPrice: 123.1
ProductStatus: Active
ProductInStock: 11
ProductId: 2
ProductCategory: Record
ProductCondition: Used
ProductDescription: Record description
ProductManufacturer: Manu2
ProductName: Record1
ProductPrice: 23.0
ProductStatus: Active
ProductInStock: 23
File --> Project Structure --> Artifacts
Select libs --> Put into WEB-INF/lib
http://localhost:8080/productList/
2 record should be shown on website
http://localhost:8080/admin/productInventory/addProduct
File --> Project Structure --> Artifacts
Output directory: /mnt/dsk0/projects/dev/Building-an-e-commerce-store-using-java-spring-framework/src/main/webapp
Select new jar --> Put into WEB-INF/lib
http://localhost:8080/admin/productInventory
Now we can add and remove images.
pom.xml
org.hibernate
javax.validation
File --> Project Structure --> Artifacts
Select new jar --> Put into WEB-INF/lib
pom.xml new dependency
spring-context
spring-security-core
spring-security-web
spring-security-config
CSRF - Cross Site Request Forgery
https://docs.spring.io/spring-security/site/docs/3.0.x/reference/appendix-schema.html
create table users(
username varchar_ignorecase(50) not null primary key,
password varchar_ignorecase(50) not null,
enabled boolean not null);
create table authorities (
username varchar_ignorecase(50) not null,
authority varchar_ignorecase(50) not null,
constraint fk_authorities_users foreign key(username) references users(username));
create unique index ix_auth_username on authorities (username,authority);
add to USERS
admin admin 1
add to AUTHORITIES
admin ROLE_USER
File --> Project Structure --> Artifacts
Select new jar --> Put into WEB-INF/lib
pom.xml new dependency
jackson-core
jackson-annotations
jackson-databind
File --> Project Structure --> Artifacts
Select new jar --> Put into WEB-INF/lib
http://localhost:8080/product/productList
drop table USERS;
drop table AUTHORITIES
redeploy app
After that:
add to USERS table:
USERSID: 1
CUSTOMERID: 1
ENABLED: 1
PASSWORD: admin
USERNAME: admin
add to AUTHORITIES table:
AUTHORITIESID: 1
AUTHORITY: ROLE_ADMIN
USERNAME: admin
http://localhost:8080/login
http://localhost:8080/admin
drop table PRODUCT;
redeploy app
File --> Project Structure --> Artifacts
Select new jar --> Put into WEB-INF/lib
Remove deprecated spring-security packages
Apply
pom.xml new dependency
org.springframework.webflow
File --> Project Structure --> Artifacts
Select new jar --> Put into WEB-INF/lib
Marley
Any questions in english: Telegram Chat
Любые вопросы на русском: Телеграм чат