Skip to content

tsadimas/spring-demo-2021

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Prerequisites

Database

Using Docker

Install Docker

docker run --name mysqldb \
-v mysqldbvol:/var/lib/mysql \
-p 3306:3306 -e MYSQL_USER=<MYSQL-USERNAME> \
-e MYSQL_PASSWORD=<MYSQL-PASSWORD> \
-e MYSQL_DATABASE=<DATABASE> \
-e MYSQL_ROOT_PASSWORD=<ROOT-PASSWORD> \
--rm -d mysql/mysql-server:latest

or

docker run --name mysqldb \
-v mysqldbvol:/var/lib/mysql \
--net=host \
-e MYSQL_ROOT_PASSWORD=<MYSQL-PASSWORD>\
-e MYSQL_ROOT_HOST='%' \
--rm -d mysql/mysql-server:latest

connect to mysql

mysql -h 127.0.0.1 -u <MYSQL-USERNAME> -p

import db schema (e.g schema.sql file)

mysql -h 127.0.0.1 -u <MYSQL-USERNAME> -p <DATABASE>  < schema.sql

Application properties

Create a file named application.properties in src/main/resources/application.properties

jdbc.url=jdbc:mysql://SERVER:PORT/DATABASE?useSSL=false&allowPublicKeyRetrieval=true
jdbc.user=USERNAME
jdbc.password=PASSWORD
jdbc.driver=com.mysql.cj.jdbc.Driver

hibernate.dialect=org.hibernate.dialect.MySQLDialect
hibernate.show_sql=true

Clone Project into Eclipse

File -> Import -> Git/Projects from Git -> Clone URI

the project url is https://github.com/tsadimas/spring-demo-2021.git

when the prompt to select the kind of project appears, select Import as general project

import_project

Next, you should convert the current project to Dynamic Web project. To accomplish this, you should right-click the project and in properties go to Project Facets Enable Faceted Project

enable_facets

and select Dynamic Web Module from the facets list.

facets

Set the default JRE runtime to be Java 11. To accomplish this, right click the project and in Java Build Path, in Libraries Tab edit the JRE System Library to point to your Java 11 runtime (setting the appropriate value to Alternate JRE).

facets

facets

To fix the errors in jsp files, you should again right click the project, and in properties go to Targeted Runtimes and select the Apache Tomcat that is connected to your eclipse workspace.

Target Runtime

Also, don't forget to convert the project to maven project (Configure->Convert to Maven Project) and select Maven--> Update Project from the menu appearing when right-clicking the project.

Clone Project in IntelliJ

Configure IntelliJ to use local Tomcat

Select Run → Edit Configurations, Then the plus (+) symbol and select Tomcat Server → Local. Target Runtime Set the location and then press the "fix" button

Target Runtime

and select an artifact to deploy. Target Runtime

Fix cannot resolve import javax.servlet.*

Go to File → Project Structure Select Modules → [your module name] → Dependencies and click the plus symbol (+)

Target Runtime and select "Application Server Libraries → Tomcat X.X.X" Target Runtime

Links

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published