Prerequisites
- You should have install java 1.8 or above.
- You should have Eclipse installed in your PC.
- Your PC should setup Maven installed and configured.
- Your PC should have installed MySQL and Server need to have user who have access to the configured database and user should able to log in to the database by user name/password.
Enable existing project to run on EAP
When Spring boot application developed it's have its embedded tomcat. So we have to remove that embedded tomcat in order to run the same project in EAP. Also I have make the project packaging as war file so we can deploy the project in to EAP.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.nirmal.springbootrest</groupId>
<artifactId>RestApiSpringBoot</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.5.RELEASE</version>
</parent>
<dependencies>
<!-- Compile -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
<!-- Provided -->
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
<!-- Runtime -->
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>6.1.0.jre8</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Then lets remove some required parameters from application.properties file as show in below. I have highlighted the commented part.
#==== connect to mysql ======#
spring.jpa.hibernate.ddl-auto=update
spring.datasource.url=jdbc:sqlserver://localhost;databaseName=TestDB
#spring.datasource.username=nirmal
#spring.datasource.password=Test123_
spring.datasource.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
spring.jpa.database-platform=org.hibernate.dialect.SQLServer2012Dialect
server.port = 8080
spring.jpa.properties.hibernate.show_sql=true
spring.jpa.properties.hibernate.use_sql_comments=false
spring.jpa.properties.hibernate.format_sql=true
#==== Logging configurations ======#
logging.level.root=WARN,INFO,ERROR
logging.level.com.baeldung=TRACE
Perform maven install
I will demonstrate it from IntelliJ as mention below. First perform maven install command by double click on "install" under maven in InelliJ as show below.
Then after successful installation you can see generated war file in target folder.
Add application properties in EAP
First lets run the JBoss EAP. For that go to the JBOSS directory and navigate to "bin" folder. Then run the "standalone.bat" in windows. (In linux run the standalone.sh file). Once EAP started you can go to Admin console in following URL. http://localhost:9990/console/App.html
Enter the admin username and password when accessing the URL. Then you should be able to see EAP web application. Then click on Configuration tab and then click on system properties. Then you should be able to see similar UI to below screen. Then click on view button.
Then you should be able to see similar image to below figure.
In order to add parameters click on Add button. Then add following details
After add those you can see similar to below figure.
Then lets deploy the war file. For that click on Back button on left top corner and then click on deployments. Then click "Add" button. Then you should be able to see similar figure to below.
Then click next button and then Click choose file and select the generated war file from target folder in the project. Then click next and then click finish. Once installation completed you should be able to see similar output on command line.
Now server started on 8090 and you should be able to access same web service from following like.
Also you can perform any action which I mentioned in my previous blog post.
Project source can be downloaded from following GIT HUB URL.
No comments:
Post a Comment