Рет қаралды 14,768
In this series, we will a full CRUD application using SpringBoot.
MyEnvironment:
MAMP (mysql server) with mysql workbench
VScode with java support extension.
System Requirements:
Java,
Maven,
MySQL Server (Database)
Visual Studio Code
Brief Overview of:
IntelliJ IDEA (Professional Edition vs Community edition)
Eclipse (SpringToolSuite) (Good for beginners)
VS-Code (text editor supported by extensions/ plug-ins)
class creation in vscode vs the other two
To check Java and Maven is installed:
java -version
mvn -v (mvn = maven)
Some useful VS-code extensions for Java:
VS-Code extensions for Java and Spring Boot:
Spring Boot Extension Pack (marketplace.visualstudio.com/...)
Language support for Java by RedHat(marketplace.visualstudio.com/...)
Maven for Java by Microsoft (marketplace.visualstudio.com/...)
Java Extension Pack by Microsoft (marketplace.visualstudio.com/...)
Spring Initializr Java by Microsoft
Debugger for Java by Microsoft
Spring Boot Dashboard for VS code (marketplace.visualstudio.com/...)
About the first CRUD (Create, Read, Update, Delete) application:
We have a company called XCARS. In order to be innovative, we want our employees to share their ideas-
about new feature that a new modern car can have.
Our Companies Website:
ideas.xcars.com
the reverse domain name will become: com.xcars.ideas
Action I:
Downloading Spring Boot package from start.spring.io/
Some additional link to Maven and Spring Boot.
mvn package
java -jar target/myproject-0.0.1-SNAPSHOT.jar
java -jar build/libs/gs-accessing-data-mysql-0.1.0.jar
(spring.io/guides/gs/accessing...)
(docs.spring.io/spring-boot/do...)
mvn spring-boot:run (start the downloaded package)
Dependencies:
mysql, web-starter, hibernate(JPA), devTools
To render webpage:
jstl, tomcat jasper
JSP:
www.javaworld.com/article/333...
JSTL:
www.tutorialspoint.com/jsp/js...
To run the project:
MySQL configuration needs to be added to application.properties
Link: (spring.io/guides/gs/accessing...)
spring.jpa.hibernate.ddl-auto=update
spring.datasource.url=jdbc:mysql://${MYSQL_HOST:localhost}:3306/db_example
spring.datasource.username=springuser
spring.datasource.password=ThePassword
none: This is the default for MySQL, no change to the database structure.
update: Hibernate changes the database according to the given Entity structures.
create: Creates the database every time, but don’t drop it when close.
create-drop: Creates the database then drops it when the SessionFactory closes.
MySQL:
Database creation: create schema ideas // or create database ideas.
create, drop, select
Building the web structure:
Building the structure: create a folder name it "webapp", inside it create another called it WEB-INF
/webapp/WEB-INF/index.jsp
Add in application.properties the preffix, suffix
create controller package inside project folder
Action II:
cmd +shift+ p
application.properties