Issue
I'm about to rewrite a Struts 2 webapp with SpringBoot & Spring Web.
How can I get started? I'm using start.spring.io with three dependencies: Spring Web, MyBatis Framework and MySQL Driver
I've opened the project in IntelliJ, built the project (no problem) but can't run the webapp as it fails to connect to my MySQL instance. Sure I realise that I'll need to provide DB URL, username, password, port, etc. but there's no configuration files included in the zip. Where do I add these so I can properly set the properties?
How can I get started with an up-to-date version of Spring Boot that includes the basic dependencies I need?
It's so frustrating to be hamstrung at the first hurdle when I know I'll be able to run the rest of the way once I get over this first step! Thank you.
Solution
You can find a file named "application.yml" or "application.properties" in directory below.
src/main/resources/
So, you have to go into that, and put the configs there.
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
spring.datasource.driver-class-name =com.mysql.jdbc.Driver
#spring.jpa.show-sql: true
Also, check to make sure you have the required dependencies added. You'll probably need these dependencies Spring Web, Spring Data JPA, and MySQL Driver. For example, in case you're using Maven. You can go check the dependencies section of POM.XML.
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.2.17.Final</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.19</version>
<scope>runtime</scope>
</dependency>
I highly recommend you to check this link.
Answered By - Amir Pezeshk
Answer Checked By - Dawn Plyler (JavaFixing Volunteer)