@SpringBootApplication
public class Application extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Application.class);
}
public static void main(String[] args) throws Exception {
SpringApplication.run(Application.class, args);
}
}
plugins {
id 'org.springframework.boot' version '2.2.4.RELEASE'
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
id 'java'
id 'war'
}
// ~abridgement~
war {
enabled = true
archiveName = 'sample.war'
}
dependencies {
// ~abridgement~
providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
}
test {
// ~abridgement~
exclude 'com/example/demo/ViewTest.class'
}
git clone
the WEB application project in your home directory.Project application.In the directory with properties
$ sudo vim application.properties
application.properties
spring.datasource.url=jdbc:mysql://RDS endpoint:3306/Database name?serverTimezone=JST
spring.datasource.username=******
spring.datasource.password=***********
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.jpa.open-in-view=true
#~abridgement~
sample.war
will be generated in project name / build / libs
.project name -0.0.1-SNAPSHOT.war
was also generated (is the content the same as sample.war?).In the project directory
$ ./gradlew build
sample.war
under tomcat / webapps
. * In my case, deploy to / opt / tomcat-9 / webapps
.$ cp sample.war /opt/tomcat-9/webapps/
$ sudo systemctl restart tomcat
If you access it like ↓, the app will run. http://EC2のエンドポイント:8080/sample/作成アプリに応じたリクエスト先
Recommended Posts