Deploy spring-boot and angular 7 application using war into tomcat 8.5Setting the base-href & context-path in spring-boot - Angular 6 applicationHow to configure port for a Spring Boot applicationSpring Boot War deployed to TomcatHow does Spring Boot control Tomcat cache?How to set Hibernate bulk_id_strategy in spring boot application?tomcat deploy module war to sub url pathHaving troubles sending emails from spring boot applicationJAR included in a project and while i am creating WAR file JAR packages are missing(SPRING BOOT)Spring Boot (jar) + JSF without web.xmlSpring boot version upgrade from 1.4.5.RELEASE to 2.0.7.RELEASEorg.springframework.jdbc.support.MetaDataAccessException: JDBC DatabaseMetaData method in spring boot
Does this put me at risk for identity theft?
"How do you solve a problem like Maria?"
How is the return type of ternary operator determined?
Validation and verification of mathematical models
What is the German idiom or expression for when someone is being hypocritical against their own teachings?
Why should public servants be apolitical?
How to help new students accept function notation
Are children a reason to be rejected for a job?
Are certificates without DNS fundamentally flawed?
Should I self-publish my novella on Amazon or try my luck getting publishers?
Why does putting a dot after the URL remove login information?
Does a 4 bladed prop have almost twice the thrust of a 2 bladed prop?
Access Remote Computer for Mostly Blind Person
Was Richard I's imprisonment by Leopold of Austria justified?
What word best describes someone who likes to do everything on his own?
Capacitors with a "/" on schematic
Decode a variable-length quantity
What are the examples (applications) of the MIPs in which the objective function has nonzero coefficients for only continuous variables?
Based on what criteria do you add/not add icons to labels within a toolbar?
Does bottle color affect mold growth?
Is the Folding Boat truly seaworthy?
Does the United States guarantee any unique freedoms?
Did Apollo leave poop on the moon?
What is an air conditioner compressor hard start kit and how does it work?
Deploy spring-boot and angular 7 application using war into tomcat 8.5
Setting the base-href & context-path in spring-boot - Angular 6 applicationHow to configure port for a Spring Boot applicationSpring Boot War deployed to TomcatHow does Spring Boot control Tomcat cache?How to set Hibernate bulk_id_strategy in spring boot application?tomcat deploy module war to sub url pathHaving troubles sending emails from spring boot applicationJAR included in a project and while i am creating WAR file JAR packages are missing(SPRING BOOT)Spring Boot (jar) + JSF without web.xmlSpring boot version upgrade from 1.4.5.RELEASE to 2.0.7.RELEASEorg.springframework.jdbc.support.MetaDataAccessException: JDBC DatabaseMetaData method in spring boot
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I am trying to deploy the Angular 7 + Spring Boot application using war into tomcat. I have followed some steps to create war with angular code. War is created successfully with UI code. But I am not able to call UI code.
When I trying to call
- localhost:8080/war-name
- localhost:8080/war-name/index.html
- localhost:8080/index.html
it shows 404
.
Web services are working properly. I can able to call them.
How I can call index.html
of my application?
Note:- I am not using spring-boot-starter-web
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<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>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.3.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com.hackthon</groupId>
<artifactId>pmoconnect</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>pmoconnect</name>
<description>PMO Connect</description>
<packaging>war</packaging>
<properties>
<java.version>1.8</java.version>
<start-class>com.hackthon.HackthonApplication</start-class>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jersey</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.0.1</version>
</dependency>
<!-- excel 2007 over -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.0.1</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-multipart</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<version>1.5.5</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-envers</artifactId>
<version>$hibernate.version</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.3</version>
<configuration>
<nodeVersion>v8.11.3</nodeVersion>
<npmVersion>6.3.0</npmVersion>
<workingDirectory>src/main/ngapp/</workingDirectory>
</configuration>
<executions>
<execution>
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
</execution>
<execution>
<id>npm run build</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>run build</arguments>
</configuration>
</execution>
<execution>
<id>prod</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>run-script build</arguments>
</configuration>
<phase>generate-resources</phase>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-resources</id>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>$project.build.directory/classes/static/</outputDirectory>
<!-- <outputDirectory>$project.build.directory/../src/main/resources/static/</outputDirectory> -->
<resources>
<resource>
<directory>/src/main/ngapp/dist/</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<packagingExcludes>WEB-INF/lib/tomcat-*.jar</packagingExcludes>
<warName>pmoconnect</warName>
</configuration>
</plugin>
</plugins>
</build>
</project>
application.properties
spring.datasource.url = jdbc:mysql://localhost:3306/elite_db?allowPublicKeyRetrieval=true&useSSL=false
spring.datasource.username = <username>
spring.datasource.password = <password>
## Hibernate Properties
# The SQL dialect makes Hibernate generate better SQL for the chosen database
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect
spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true
# Hibernate ddl auto (create, create-drop, validate, update)
spring.jpa.hibernate.ddl-auto = update
org.hibernate.envers.audit_table_suffix = _AUDIT_LOG
HackthonApplication.java
@SpringBootApplication
@ComponentScan
public class HackthonApplication
public static void main(String[] args)
SpringApplication.run(HackthonApplication.class, args);
index.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>PMO Connect</title>
<base href="./">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
</head>
<body>
<app-root></app-root>
<script type="text/javascript" src="runtime.js"></script>
<script type="text/javascript" src="es2015-polyfills.js" nomodule></script>
<script type="text/javascript" src="polyfills.js"></script>
<script type="text/javascript" src="styles.js"></script>
<script type="text/javascript" src="vendor.js"></script>
<script type="text/javascript" src="main.js"></script>
</body>
</html>
war file
tomcat logs
2019-03-27 10:34:19.134 INFO 18464 --- [ost-startStop-2] com.hackthon.HackthonApplication : No active profile set, falling back to default profiles: default
2019-03-27 10:34:19.291 INFO 18464 --- [ost-startStop-2] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2019-03-27 10:34:22.558 INFO 18464 --- [ost-startStop-2] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode.
2019-03-27 10:34:22.977 INFO 18464 --- [ost-startStop-2] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 372ms. Found 6 repository interfaces.
2019-03-27 10:34:24.386 INFO 18464 --- [ost-startStop-2] o.a.c.c.C.[.[localhost].[/pmoconnect] : Initializing Spring embedded WebApplicationContext
2019-03-27 10:34:24.386 INFO 18464 --- [ost-startStop-2] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 5094 ms
2019-03-27 10:34:24.809 INFO 18464 --- [ost-startStop-2] o.s.b.a.jersey.JerseyAutoConfiguration : Configuring existing registration for Jersey servlet 'com.hackthon.config.JerseyConfiguration'
2019-03-27 10:34:25.046 INFO 18464 --- [ost-startStop-2] o.s.boot.web.servlet.RegistrationBean : Servlet com.hackthon.config.JerseyConfiguration was not registered (possibly already registered?)
2019-03-27 10:34:25.628 INFO 18464 --- [ost-startStop-2] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2019-03-27 10:34:26.473 INFO 18464 --- [ost-startStop-2] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2019-03-27 10:34:26.815 INFO 18464 --- [ost-startStop-2] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2019-03-27 10:34:27.465 INFO 18464 --- [ost-startStop-2] org.hibernate.Version : HHH000412: Hibernate Core 5.3.7.Final
2019-03-27 10:34:27.472 INFO 18464 --- [ost-startStop-2] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2019-03-27 10:34:28.996 INFO 18464 --- [ost-startStop-2] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations 5.0.4.Final
2019-03-27 10:34:30.597 INFO 18464 --- [ost-startStop-2] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL5InnoDBDialect
2019-03-27 10:34:30.951 INFO 18464 --- [ost-startStop-2] o.h.e.boot.internal.EnversServiceImpl : Envers integration enabled? : true
2019-03-27 10:34:41.272 INFO 18464 --- [ost-startStop-2] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2019-03-27 10:34:43.158 INFO 18464 --- [ost-startStop-2] o.h.h.i.QueryTranslatorFactoryInitiator : HHH000397: Using ASTQueryTranslatorFactory
2019-03-27 10:34:46.554 INFO 18464 --- [ost-startStop-2] com.hackthon.HackthonApplication : Started HackthonApplication in 29.239 seconds (JVM running for 143.14)
2019-03-27 10:34:46.944 INFO 18464 --- [ost-startStop-2] org.apache.jasper.servlet.TldScanner : At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
2019-03-27 10:34:50.219 WARN 18464 --- [ost-startStop-2] org.glassfish.jersey.internal.Errors : The following warnings have been detected: WARNING: A HTTP GET method, public javax.ws.rs.core.Response com.hackthon.service.WSFGMapping.getMappings(java.lang.String), should not consume any entity.
2019-03-27 10:34:50.348 INFO 18464 --- [ost-startStop-2] org.apache.catalina.startup.HostConfig : Deployment of web application archive [C:UserskaukharemyWorkspace.metadata.pluginsorg.eclipse.wst.server.coretmp1webappspmoconnect.war] has finished in [68,229] ms
java angular spring spring-boot
|
show 2 more comments
I am trying to deploy the Angular 7 + Spring Boot application using war into tomcat. I have followed some steps to create war with angular code. War is created successfully with UI code. But I am not able to call UI code.
When I trying to call
- localhost:8080/war-name
- localhost:8080/war-name/index.html
- localhost:8080/index.html
it shows 404
.
Web services are working properly. I can able to call them.
How I can call index.html
of my application?
Note:- I am not using spring-boot-starter-web
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<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>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.3.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com.hackthon</groupId>
<artifactId>pmoconnect</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>pmoconnect</name>
<description>PMO Connect</description>
<packaging>war</packaging>
<properties>
<java.version>1.8</java.version>
<start-class>com.hackthon.HackthonApplication</start-class>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jersey</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.0.1</version>
</dependency>
<!-- excel 2007 over -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.0.1</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-multipart</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<version>1.5.5</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-envers</artifactId>
<version>$hibernate.version</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.3</version>
<configuration>
<nodeVersion>v8.11.3</nodeVersion>
<npmVersion>6.3.0</npmVersion>
<workingDirectory>src/main/ngapp/</workingDirectory>
</configuration>
<executions>
<execution>
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
</execution>
<execution>
<id>npm run build</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>run build</arguments>
</configuration>
</execution>
<execution>
<id>prod</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>run-script build</arguments>
</configuration>
<phase>generate-resources</phase>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-resources</id>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>$project.build.directory/classes/static/</outputDirectory>
<!-- <outputDirectory>$project.build.directory/../src/main/resources/static/</outputDirectory> -->
<resources>
<resource>
<directory>/src/main/ngapp/dist/</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<packagingExcludes>WEB-INF/lib/tomcat-*.jar</packagingExcludes>
<warName>pmoconnect</warName>
</configuration>
</plugin>
</plugins>
</build>
</project>
application.properties
spring.datasource.url = jdbc:mysql://localhost:3306/elite_db?allowPublicKeyRetrieval=true&useSSL=false
spring.datasource.username = <username>
spring.datasource.password = <password>
## Hibernate Properties
# The SQL dialect makes Hibernate generate better SQL for the chosen database
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect
spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true
# Hibernate ddl auto (create, create-drop, validate, update)
spring.jpa.hibernate.ddl-auto = update
org.hibernate.envers.audit_table_suffix = _AUDIT_LOG
HackthonApplication.java
@SpringBootApplication
@ComponentScan
public class HackthonApplication
public static void main(String[] args)
SpringApplication.run(HackthonApplication.class, args);
index.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>PMO Connect</title>
<base href="./">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
</head>
<body>
<app-root></app-root>
<script type="text/javascript" src="runtime.js"></script>
<script type="text/javascript" src="es2015-polyfills.js" nomodule></script>
<script type="text/javascript" src="polyfills.js"></script>
<script type="text/javascript" src="styles.js"></script>
<script type="text/javascript" src="vendor.js"></script>
<script type="text/javascript" src="main.js"></script>
</body>
</html>
war file
tomcat logs
2019-03-27 10:34:19.134 INFO 18464 --- [ost-startStop-2] com.hackthon.HackthonApplication : No active profile set, falling back to default profiles: default
2019-03-27 10:34:19.291 INFO 18464 --- [ost-startStop-2] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2019-03-27 10:34:22.558 INFO 18464 --- [ost-startStop-2] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode.
2019-03-27 10:34:22.977 INFO 18464 --- [ost-startStop-2] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 372ms. Found 6 repository interfaces.
2019-03-27 10:34:24.386 INFO 18464 --- [ost-startStop-2] o.a.c.c.C.[.[localhost].[/pmoconnect] : Initializing Spring embedded WebApplicationContext
2019-03-27 10:34:24.386 INFO 18464 --- [ost-startStop-2] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 5094 ms
2019-03-27 10:34:24.809 INFO 18464 --- [ost-startStop-2] o.s.b.a.jersey.JerseyAutoConfiguration : Configuring existing registration for Jersey servlet 'com.hackthon.config.JerseyConfiguration'
2019-03-27 10:34:25.046 INFO 18464 --- [ost-startStop-2] o.s.boot.web.servlet.RegistrationBean : Servlet com.hackthon.config.JerseyConfiguration was not registered (possibly already registered?)
2019-03-27 10:34:25.628 INFO 18464 --- [ost-startStop-2] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2019-03-27 10:34:26.473 INFO 18464 --- [ost-startStop-2] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2019-03-27 10:34:26.815 INFO 18464 --- [ost-startStop-2] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2019-03-27 10:34:27.465 INFO 18464 --- [ost-startStop-2] org.hibernate.Version : HHH000412: Hibernate Core 5.3.7.Final
2019-03-27 10:34:27.472 INFO 18464 --- [ost-startStop-2] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2019-03-27 10:34:28.996 INFO 18464 --- [ost-startStop-2] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations 5.0.4.Final
2019-03-27 10:34:30.597 INFO 18464 --- [ost-startStop-2] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL5InnoDBDialect
2019-03-27 10:34:30.951 INFO 18464 --- [ost-startStop-2] o.h.e.boot.internal.EnversServiceImpl : Envers integration enabled? : true
2019-03-27 10:34:41.272 INFO 18464 --- [ost-startStop-2] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2019-03-27 10:34:43.158 INFO 18464 --- [ost-startStop-2] o.h.h.i.QueryTranslatorFactoryInitiator : HHH000397: Using ASTQueryTranslatorFactory
2019-03-27 10:34:46.554 INFO 18464 --- [ost-startStop-2] com.hackthon.HackthonApplication : Started HackthonApplication in 29.239 seconds (JVM running for 143.14)
2019-03-27 10:34:46.944 INFO 18464 --- [ost-startStop-2] org.apache.jasper.servlet.TldScanner : At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
2019-03-27 10:34:50.219 WARN 18464 --- [ost-startStop-2] org.glassfish.jersey.internal.Errors : The following warnings have been detected: WARNING: A HTTP GET method, public javax.ws.rs.core.Response com.hackthon.service.WSFGMapping.getMappings(java.lang.String), should not consume any entity.
2019-03-27 10:34:50.348 INFO 18464 --- [ost-startStop-2] org.apache.catalina.startup.HostConfig : Deployment of web application archive [C:UserskaukharemyWorkspace.metadata.pluginsorg.eclipse.wst.server.coretmp1webappspmoconnect.war] has finished in [68,229] ms
java angular spring spring-boot
please post your index.html
– Ganesh Gudghe
Mar 26 at 6:56
@GaneshGudghe updated.
– Kaustubh Khare
Mar 26 at 7:01
Please check my answer it will solve your issue
– Ganesh Gudghe
Mar 26 at 7:02
can you try adding context path in your properties "server.servlet.context-path=/<<yourappname>>" ?
– Akhil S K
Mar 26 at 8:27
@AkhilSK I tried this one, but same 404 error.
– Kaustubh Khare
Mar 26 at 8:42
|
show 2 more comments
I am trying to deploy the Angular 7 + Spring Boot application using war into tomcat. I have followed some steps to create war with angular code. War is created successfully with UI code. But I am not able to call UI code.
When I trying to call
- localhost:8080/war-name
- localhost:8080/war-name/index.html
- localhost:8080/index.html
it shows 404
.
Web services are working properly. I can able to call them.
How I can call index.html
of my application?
Note:- I am not using spring-boot-starter-web
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<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>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.3.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com.hackthon</groupId>
<artifactId>pmoconnect</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>pmoconnect</name>
<description>PMO Connect</description>
<packaging>war</packaging>
<properties>
<java.version>1.8</java.version>
<start-class>com.hackthon.HackthonApplication</start-class>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jersey</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.0.1</version>
</dependency>
<!-- excel 2007 over -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.0.1</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-multipart</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<version>1.5.5</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-envers</artifactId>
<version>$hibernate.version</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.3</version>
<configuration>
<nodeVersion>v8.11.3</nodeVersion>
<npmVersion>6.3.0</npmVersion>
<workingDirectory>src/main/ngapp/</workingDirectory>
</configuration>
<executions>
<execution>
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
</execution>
<execution>
<id>npm run build</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>run build</arguments>
</configuration>
</execution>
<execution>
<id>prod</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>run-script build</arguments>
</configuration>
<phase>generate-resources</phase>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-resources</id>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>$project.build.directory/classes/static/</outputDirectory>
<!-- <outputDirectory>$project.build.directory/../src/main/resources/static/</outputDirectory> -->
<resources>
<resource>
<directory>/src/main/ngapp/dist/</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<packagingExcludes>WEB-INF/lib/tomcat-*.jar</packagingExcludes>
<warName>pmoconnect</warName>
</configuration>
</plugin>
</plugins>
</build>
</project>
application.properties
spring.datasource.url = jdbc:mysql://localhost:3306/elite_db?allowPublicKeyRetrieval=true&useSSL=false
spring.datasource.username = <username>
spring.datasource.password = <password>
## Hibernate Properties
# The SQL dialect makes Hibernate generate better SQL for the chosen database
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect
spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true
# Hibernate ddl auto (create, create-drop, validate, update)
spring.jpa.hibernate.ddl-auto = update
org.hibernate.envers.audit_table_suffix = _AUDIT_LOG
HackthonApplication.java
@SpringBootApplication
@ComponentScan
public class HackthonApplication
public static void main(String[] args)
SpringApplication.run(HackthonApplication.class, args);
index.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>PMO Connect</title>
<base href="./">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
</head>
<body>
<app-root></app-root>
<script type="text/javascript" src="runtime.js"></script>
<script type="text/javascript" src="es2015-polyfills.js" nomodule></script>
<script type="text/javascript" src="polyfills.js"></script>
<script type="text/javascript" src="styles.js"></script>
<script type="text/javascript" src="vendor.js"></script>
<script type="text/javascript" src="main.js"></script>
</body>
</html>
war file
tomcat logs
2019-03-27 10:34:19.134 INFO 18464 --- [ost-startStop-2] com.hackthon.HackthonApplication : No active profile set, falling back to default profiles: default
2019-03-27 10:34:19.291 INFO 18464 --- [ost-startStop-2] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2019-03-27 10:34:22.558 INFO 18464 --- [ost-startStop-2] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode.
2019-03-27 10:34:22.977 INFO 18464 --- [ost-startStop-2] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 372ms. Found 6 repository interfaces.
2019-03-27 10:34:24.386 INFO 18464 --- [ost-startStop-2] o.a.c.c.C.[.[localhost].[/pmoconnect] : Initializing Spring embedded WebApplicationContext
2019-03-27 10:34:24.386 INFO 18464 --- [ost-startStop-2] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 5094 ms
2019-03-27 10:34:24.809 INFO 18464 --- [ost-startStop-2] o.s.b.a.jersey.JerseyAutoConfiguration : Configuring existing registration for Jersey servlet 'com.hackthon.config.JerseyConfiguration'
2019-03-27 10:34:25.046 INFO 18464 --- [ost-startStop-2] o.s.boot.web.servlet.RegistrationBean : Servlet com.hackthon.config.JerseyConfiguration was not registered (possibly already registered?)
2019-03-27 10:34:25.628 INFO 18464 --- [ost-startStop-2] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2019-03-27 10:34:26.473 INFO 18464 --- [ost-startStop-2] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2019-03-27 10:34:26.815 INFO 18464 --- [ost-startStop-2] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2019-03-27 10:34:27.465 INFO 18464 --- [ost-startStop-2] org.hibernate.Version : HHH000412: Hibernate Core 5.3.7.Final
2019-03-27 10:34:27.472 INFO 18464 --- [ost-startStop-2] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2019-03-27 10:34:28.996 INFO 18464 --- [ost-startStop-2] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations 5.0.4.Final
2019-03-27 10:34:30.597 INFO 18464 --- [ost-startStop-2] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL5InnoDBDialect
2019-03-27 10:34:30.951 INFO 18464 --- [ost-startStop-2] o.h.e.boot.internal.EnversServiceImpl : Envers integration enabled? : true
2019-03-27 10:34:41.272 INFO 18464 --- [ost-startStop-2] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2019-03-27 10:34:43.158 INFO 18464 --- [ost-startStop-2] o.h.h.i.QueryTranslatorFactoryInitiator : HHH000397: Using ASTQueryTranslatorFactory
2019-03-27 10:34:46.554 INFO 18464 --- [ost-startStop-2] com.hackthon.HackthonApplication : Started HackthonApplication in 29.239 seconds (JVM running for 143.14)
2019-03-27 10:34:46.944 INFO 18464 --- [ost-startStop-2] org.apache.jasper.servlet.TldScanner : At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
2019-03-27 10:34:50.219 WARN 18464 --- [ost-startStop-2] org.glassfish.jersey.internal.Errors : The following warnings have been detected: WARNING: A HTTP GET method, public javax.ws.rs.core.Response com.hackthon.service.WSFGMapping.getMappings(java.lang.String), should not consume any entity.
2019-03-27 10:34:50.348 INFO 18464 --- [ost-startStop-2] org.apache.catalina.startup.HostConfig : Deployment of web application archive [C:UserskaukharemyWorkspace.metadata.pluginsorg.eclipse.wst.server.coretmp1webappspmoconnect.war] has finished in [68,229] ms
java angular spring spring-boot
I am trying to deploy the Angular 7 + Spring Boot application using war into tomcat. I have followed some steps to create war with angular code. War is created successfully with UI code. But I am not able to call UI code.
When I trying to call
- localhost:8080/war-name
- localhost:8080/war-name/index.html
- localhost:8080/index.html
it shows 404
.
Web services are working properly. I can able to call them.
How I can call index.html
of my application?
Note:- I am not using spring-boot-starter-web
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<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>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.3.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com.hackthon</groupId>
<artifactId>pmoconnect</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>pmoconnect</name>
<description>PMO Connect</description>
<packaging>war</packaging>
<properties>
<java.version>1.8</java.version>
<start-class>com.hackthon.HackthonApplication</start-class>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jersey</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.0.1</version>
</dependency>
<!-- excel 2007 over -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.0.1</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-multipart</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<version>1.5.5</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-envers</artifactId>
<version>$hibernate.version</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.3</version>
<configuration>
<nodeVersion>v8.11.3</nodeVersion>
<npmVersion>6.3.0</npmVersion>
<workingDirectory>src/main/ngapp/</workingDirectory>
</configuration>
<executions>
<execution>
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
</execution>
<execution>
<id>npm run build</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>run build</arguments>
</configuration>
</execution>
<execution>
<id>prod</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>run-script build</arguments>
</configuration>
<phase>generate-resources</phase>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-resources</id>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>$project.build.directory/classes/static/</outputDirectory>
<!-- <outputDirectory>$project.build.directory/../src/main/resources/static/</outputDirectory> -->
<resources>
<resource>
<directory>/src/main/ngapp/dist/</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<packagingExcludes>WEB-INF/lib/tomcat-*.jar</packagingExcludes>
<warName>pmoconnect</warName>
</configuration>
</plugin>
</plugins>
</build>
</project>
application.properties
spring.datasource.url = jdbc:mysql://localhost:3306/elite_db?allowPublicKeyRetrieval=true&useSSL=false
spring.datasource.username = <username>
spring.datasource.password = <password>
## Hibernate Properties
# The SQL dialect makes Hibernate generate better SQL for the chosen database
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect
spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true
# Hibernate ddl auto (create, create-drop, validate, update)
spring.jpa.hibernate.ddl-auto = update
org.hibernate.envers.audit_table_suffix = _AUDIT_LOG
HackthonApplication.java
@SpringBootApplication
@ComponentScan
public class HackthonApplication
public static void main(String[] args)
SpringApplication.run(HackthonApplication.class, args);
index.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>PMO Connect</title>
<base href="./">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
</head>
<body>
<app-root></app-root>
<script type="text/javascript" src="runtime.js"></script>
<script type="text/javascript" src="es2015-polyfills.js" nomodule></script>
<script type="text/javascript" src="polyfills.js"></script>
<script type="text/javascript" src="styles.js"></script>
<script type="text/javascript" src="vendor.js"></script>
<script type="text/javascript" src="main.js"></script>
</body>
</html>
war file
tomcat logs
2019-03-27 10:34:19.134 INFO 18464 --- [ost-startStop-2] com.hackthon.HackthonApplication : No active profile set, falling back to default profiles: default
2019-03-27 10:34:19.291 INFO 18464 --- [ost-startStop-2] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2019-03-27 10:34:22.558 INFO 18464 --- [ost-startStop-2] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode.
2019-03-27 10:34:22.977 INFO 18464 --- [ost-startStop-2] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 372ms. Found 6 repository interfaces.
2019-03-27 10:34:24.386 INFO 18464 --- [ost-startStop-2] o.a.c.c.C.[.[localhost].[/pmoconnect] : Initializing Spring embedded WebApplicationContext
2019-03-27 10:34:24.386 INFO 18464 --- [ost-startStop-2] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 5094 ms
2019-03-27 10:34:24.809 INFO 18464 --- [ost-startStop-2] o.s.b.a.jersey.JerseyAutoConfiguration : Configuring existing registration for Jersey servlet 'com.hackthon.config.JerseyConfiguration'
2019-03-27 10:34:25.046 INFO 18464 --- [ost-startStop-2] o.s.boot.web.servlet.RegistrationBean : Servlet com.hackthon.config.JerseyConfiguration was not registered (possibly already registered?)
2019-03-27 10:34:25.628 INFO 18464 --- [ost-startStop-2] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2019-03-27 10:34:26.473 INFO 18464 --- [ost-startStop-2] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2019-03-27 10:34:26.815 INFO 18464 --- [ost-startStop-2] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2019-03-27 10:34:27.465 INFO 18464 --- [ost-startStop-2] org.hibernate.Version : HHH000412: Hibernate Core 5.3.7.Final
2019-03-27 10:34:27.472 INFO 18464 --- [ost-startStop-2] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2019-03-27 10:34:28.996 INFO 18464 --- [ost-startStop-2] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations 5.0.4.Final
2019-03-27 10:34:30.597 INFO 18464 --- [ost-startStop-2] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL5InnoDBDialect
2019-03-27 10:34:30.951 INFO 18464 --- [ost-startStop-2] o.h.e.boot.internal.EnversServiceImpl : Envers integration enabled? : true
2019-03-27 10:34:41.272 INFO 18464 --- [ost-startStop-2] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2019-03-27 10:34:43.158 INFO 18464 --- [ost-startStop-2] o.h.h.i.QueryTranslatorFactoryInitiator : HHH000397: Using ASTQueryTranslatorFactory
2019-03-27 10:34:46.554 INFO 18464 --- [ost-startStop-2] com.hackthon.HackthonApplication : Started HackthonApplication in 29.239 seconds (JVM running for 143.14)
2019-03-27 10:34:46.944 INFO 18464 --- [ost-startStop-2] org.apache.jasper.servlet.TldScanner : At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
2019-03-27 10:34:50.219 WARN 18464 --- [ost-startStop-2] org.glassfish.jersey.internal.Errors : The following warnings have been detected: WARNING: A HTTP GET method, public javax.ws.rs.core.Response com.hackthon.service.WSFGMapping.getMappings(java.lang.String), should not consume any entity.
2019-03-27 10:34:50.348 INFO 18464 --- [ost-startStop-2] org.apache.catalina.startup.HostConfig : Deployment of web application archive [C:UserskaukharemyWorkspace.metadata.pluginsorg.eclipse.wst.server.coretmp1webappspmoconnect.war] has finished in [68,229] ms
java angular spring spring-boot
java angular spring spring-boot
edited Mar 27 at 5:25
Kaustubh Khare
asked Mar 26 at 6:51
Kaustubh KhareKaustubh Khare
1,69016 silver badges30 bronze badges
1,69016 silver badges30 bronze badges
please post your index.html
– Ganesh Gudghe
Mar 26 at 6:56
@GaneshGudghe updated.
– Kaustubh Khare
Mar 26 at 7:01
Please check my answer it will solve your issue
– Ganesh Gudghe
Mar 26 at 7:02
can you try adding context path in your properties "server.servlet.context-path=/<<yourappname>>" ?
– Akhil S K
Mar 26 at 8:27
@AkhilSK I tried this one, but same 404 error.
– Kaustubh Khare
Mar 26 at 8:42
|
show 2 more comments
please post your index.html
– Ganesh Gudghe
Mar 26 at 6:56
@GaneshGudghe updated.
– Kaustubh Khare
Mar 26 at 7:01
Please check my answer it will solve your issue
– Ganesh Gudghe
Mar 26 at 7:02
can you try adding context path in your properties "server.servlet.context-path=/<<yourappname>>" ?
– Akhil S K
Mar 26 at 8:27
@AkhilSK I tried this one, but same 404 error.
– Kaustubh Khare
Mar 26 at 8:42
please post your index.html
– Ganesh Gudghe
Mar 26 at 6:56
please post your index.html
– Ganesh Gudghe
Mar 26 at 6:56
@GaneshGudghe updated.
– Kaustubh Khare
Mar 26 at 7:01
@GaneshGudghe updated.
– Kaustubh Khare
Mar 26 at 7:01
Please check my answer it will solve your issue
– Ganesh Gudghe
Mar 26 at 7:02
Please check my answer it will solve your issue
– Ganesh Gudghe
Mar 26 at 7:02
can you try adding context path in your properties "server.servlet.context-path=/<<yourappname>>" ?
– Akhil S K
Mar 26 at 8:27
can you try adding context path in your properties "server.servlet.context-path=/<<yourappname>>" ?
– Akhil S K
Mar 26 at 8:27
@AkhilSK I tried this one, but same 404 error.
– Kaustubh Khare
Mar 26 at 8:42
@AkhilSK I tried this one, but same 404 error.
– Kaustubh Khare
Mar 26 at 8:42
|
show 2 more comments
3 Answers
3
active
oldest
votes
I also had the same issue and I resolved by adding following script inside index.html
<base href="/" id="baseHref">
<script>
(function()
document.getElementById('baseHref').href = '/' + window.location.pathname.split('/')[1] + "/";
)();
</script>
I think it will solve your problem.
No luck. It is showing 404.
– Kaustubh Khare
Mar 26 at 8:25
add a comment |
Kaustubh,
Looks like you forgot to extend your application from SpringBootServletInitializer
. More about that you can read in official documentation.
Long story short please try following code for your main class.
@SpringBootApplication
@ComponentScan
public class HackthonApplication extends SpringBootServletInitializer
public static void main(String[] args)
SpringApplication.run(HackthonApplication.class, args);
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder)
return builder.sources(HackthonApplication.class);
Hope this will solve your issue.
Still not able to findindex.html
. It shows 404.
– Kaustubh Khare
Mar 27 at 5:09
@KaustubhKhare could you than share the log file from the tomcat console? Looks like issue is also somewhere in your code. WithoutSpringBootServletInitializer
it cannot work, but even with with it it can also not working because of other issues in code. In what I'm sure that the first edition of your code won't work withoutSpringBootServletInitializer
.
– Mikita Berazouski
Mar 27 at 5:19
I am able to call web services withoutSpringBootServletInitializer
code.
– Kaustubh Khare
Mar 27 at 5:22
I have added tomcat logs. It is not giving any errors.
– Kaustubh Khare
Mar 27 at 5:26
Let me see. FYI, updated the URL to the documentation - use this: docs.spring.io/spring-boot/docs/1.5.6.RELEASE/reference/…
– Mikita Berazouski
Mar 27 at 5:27
|
show 2 more comments
I have not found any solution to the problem using spring-jersey
. So I have decided to use spring-web
.
Required changes I have made to project,
pom.xml
Remove spring-jersey
and add spring-web
,
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
package.json
"start": "ng serve --proxy-config proxy.conf.json",
"build": "ng build --base-href="./"",
Add proxy.conf.json file into base path of angular app,
"/api":
"target": "http://localhost:8080",
"secure": false
HackthonApplication.java
public class HackthonApplication extends SpringBootServletInitializer
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application)
return application.sources(HackthonApplication.class);
And there are some annotations changes for webservice. This is because i have changed spring-jersey
to spring-web
.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55351303%2fdeploy-spring-boot-and-angular-7-application-using-war-into-tomcat-8-5%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
I also had the same issue and I resolved by adding following script inside index.html
<base href="/" id="baseHref">
<script>
(function()
document.getElementById('baseHref').href = '/' + window.location.pathname.split('/')[1] + "/";
)();
</script>
I think it will solve your problem.
No luck. It is showing 404.
– Kaustubh Khare
Mar 26 at 8:25
add a comment |
I also had the same issue and I resolved by adding following script inside index.html
<base href="/" id="baseHref">
<script>
(function()
document.getElementById('baseHref').href = '/' + window.location.pathname.split('/')[1] + "/";
)();
</script>
I think it will solve your problem.
No luck. It is showing 404.
– Kaustubh Khare
Mar 26 at 8:25
add a comment |
I also had the same issue and I resolved by adding following script inside index.html
<base href="/" id="baseHref">
<script>
(function()
document.getElementById('baseHref').href = '/' + window.location.pathname.split('/')[1] + "/";
)();
</script>
I think it will solve your problem.
I also had the same issue and I resolved by adding following script inside index.html
<base href="/" id="baseHref">
<script>
(function()
document.getElementById('baseHref').href = '/' + window.location.pathname.split('/')[1] + "/";
)();
</script>
I think it will solve your problem.
answered Mar 26 at 7:00
Ganesh GudgheGanesh Gudghe
6756 silver badges26 bronze badges
6756 silver badges26 bronze badges
No luck. It is showing 404.
– Kaustubh Khare
Mar 26 at 8:25
add a comment |
No luck. It is showing 404.
– Kaustubh Khare
Mar 26 at 8:25
No luck. It is showing 404.
– Kaustubh Khare
Mar 26 at 8:25
No luck. It is showing 404.
– Kaustubh Khare
Mar 26 at 8:25
add a comment |
Kaustubh,
Looks like you forgot to extend your application from SpringBootServletInitializer
. More about that you can read in official documentation.
Long story short please try following code for your main class.
@SpringBootApplication
@ComponentScan
public class HackthonApplication extends SpringBootServletInitializer
public static void main(String[] args)
SpringApplication.run(HackthonApplication.class, args);
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder)
return builder.sources(HackthonApplication.class);
Hope this will solve your issue.
Still not able to findindex.html
. It shows 404.
– Kaustubh Khare
Mar 27 at 5:09
@KaustubhKhare could you than share the log file from the tomcat console? Looks like issue is also somewhere in your code. WithoutSpringBootServletInitializer
it cannot work, but even with with it it can also not working because of other issues in code. In what I'm sure that the first edition of your code won't work withoutSpringBootServletInitializer
.
– Mikita Berazouski
Mar 27 at 5:19
I am able to call web services withoutSpringBootServletInitializer
code.
– Kaustubh Khare
Mar 27 at 5:22
I have added tomcat logs. It is not giving any errors.
– Kaustubh Khare
Mar 27 at 5:26
Let me see. FYI, updated the URL to the documentation - use this: docs.spring.io/spring-boot/docs/1.5.6.RELEASE/reference/…
– Mikita Berazouski
Mar 27 at 5:27
|
show 2 more comments
Kaustubh,
Looks like you forgot to extend your application from SpringBootServletInitializer
. More about that you can read in official documentation.
Long story short please try following code for your main class.
@SpringBootApplication
@ComponentScan
public class HackthonApplication extends SpringBootServletInitializer
public static void main(String[] args)
SpringApplication.run(HackthonApplication.class, args);
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder)
return builder.sources(HackthonApplication.class);
Hope this will solve your issue.
Still not able to findindex.html
. It shows 404.
– Kaustubh Khare
Mar 27 at 5:09
@KaustubhKhare could you than share the log file from the tomcat console? Looks like issue is also somewhere in your code. WithoutSpringBootServletInitializer
it cannot work, but even with with it it can also not working because of other issues in code. In what I'm sure that the first edition of your code won't work withoutSpringBootServletInitializer
.
– Mikita Berazouski
Mar 27 at 5:19
I am able to call web services withoutSpringBootServletInitializer
code.
– Kaustubh Khare
Mar 27 at 5:22
I have added tomcat logs. It is not giving any errors.
– Kaustubh Khare
Mar 27 at 5:26
Let me see. FYI, updated the URL to the documentation - use this: docs.spring.io/spring-boot/docs/1.5.6.RELEASE/reference/…
– Mikita Berazouski
Mar 27 at 5:27
|
show 2 more comments
Kaustubh,
Looks like you forgot to extend your application from SpringBootServletInitializer
. More about that you can read in official documentation.
Long story short please try following code for your main class.
@SpringBootApplication
@ComponentScan
public class HackthonApplication extends SpringBootServletInitializer
public static void main(String[] args)
SpringApplication.run(HackthonApplication.class, args);
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder)
return builder.sources(HackthonApplication.class);
Hope this will solve your issue.
Kaustubh,
Looks like you forgot to extend your application from SpringBootServletInitializer
. More about that you can read in official documentation.
Long story short please try following code for your main class.
@SpringBootApplication
@ComponentScan
public class HackthonApplication extends SpringBootServletInitializer
public static void main(String[] args)
SpringApplication.run(HackthonApplication.class, args);
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder)
return builder.sources(HackthonApplication.class);
Hope this will solve your issue.
edited Mar 27 at 5:27
answered Mar 26 at 11:56
Mikita BerazouskiMikita Berazouski
6323 silver badges13 bronze badges
6323 silver badges13 bronze badges
Still not able to findindex.html
. It shows 404.
– Kaustubh Khare
Mar 27 at 5:09
@KaustubhKhare could you than share the log file from the tomcat console? Looks like issue is also somewhere in your code. WithoutSpringBootServletInitializer
it cannot work, but even with with it it can also not working because of other issues in code. In what I'm sure that the first edition of your code won't work withoutSpringBootServletInitializer
.
– Mikita Berazouski
Mar 27 at 5:19
I am able to call web services withoutSpringBootServletInitializer
code.
– Kaustubh Khare
Mar 27 at 5:22
I have added tomcat logs. It is not giving any errors.
– Kaustubh Khare
Mar 27 at 5:26
Let me see. FYI, updated the URL to the documentation - use this: docs.spring.io/spring-boot/docs/1.5.6.RELEASE/reference/…
– Mikita Berazouski
Mar 27 at 5:27
|
show 2 more comments
Still not able to findindex.html
. It shows 404.
– Kaustubh Khare
Mar 27 at 5:09
@KaustubhKhare could you than share the log file from the tomcat console? Looks like issue is also somewhere in your code. WithoutSpringBootServletInitializer
it cannot work, but even with with it it can also not working because of other issues in code. In what I'm sure that the first edition of your code won't work withoutSpringBootServletInitializer
.
– Mikita Berazouski
Mar 27 at 5:19
I am able to call web services withoutSpringBootServletInitializer
code.
– Kaustubh Khare
Mar 27 at 5:22
I have added tomcat logs. It is not giving any errors.
– Kaustubh Khare
Mar 27 at 5:26
Let me see. FYI, updated the URL to the documentation - use this: docs.spring.io/spring-boot/docs/1.5.6.RELEASE/reference/…
– Mikita Berazouski
Mar 27 at 5:27
Still not able to find
index.html
. It shows 404.– Kaustubh Khare
Mar 27 at 5:09
Still not able to find
index.html
. It shows 404.– Kaustubh Khare
Mar 27 at 5:09
@KaustubhKhare could you than share the log file from the tomcat console? Looks like issue is also somewhere in your code. Without
SpringBootServletInitializer
it cannot work, but even with with it it can also not working because of other issues in code. In what I'm sure that the first edition of your code won't work without SpringBootServletInitializer
.– Mikita Berazouski
Mar 27 at 5:19
@KaustubhKhare could you than share the log file from the tomcat console? Looks like issue is also somewhere in your code. Without
SpringBootServletInitializer
it cannot work, but even with with it it can also not working because of other issues in code. In what I'm sure that the first edition of your code won't work without SpringBootServletInitializer
.– Mikita Berazouski
Mar 27 at 5:19
I am able to call web services without
SpringBootServletInitializer
code.– Kaustubh Khare
Mar 27 at 5:22
I am able to call web services without
SpringBootServletInitializer
code.– Kaustubh Khare
Mar 27 at 5:22
I have added tomcat logs. It is not giving any errors.
– Kaustubh Khare
Mar 27 at 5:26
I have added tomcat logs. It is not giving any errors.
– Kaustubh Khare
Mar 27 at 5:26
Let me see. FYI, updated the URL to the documentation - use this: docs.spring.io/spring-boot/docs/1.5.6.RELEASE/reference/…
– Mikita Berazouski
Mar 27 at 5:27
Let me see. FYI, updated the URL to the documentation - use this: docs.spring.io/spring-boot/docs/1.5.6.RELEASE/reference/…
– Mikita Berazouski
Mar 27 at 5:27
|
show 2 more comments
I have not found any solution to the problem using spring-jersey
. So I have decided to use spring-web
.
Required changes I have made to project,
pom.xml
Remove spring-jersey
and add spring-web
,
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
package.json
"start": "ng serve --proxy-config proxy.conf.json",
"build": "ng build --base-href="./"",
Add proxy.conf.json file into base path of angular app,
"/api":
"target": "http://localhost:8080",
"secure": false
HackthonApplication.java
public class HackthonApplication extends SpringBootServletInitializer
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application)
return application.sources(HackthonApplication.class);
And there are some annotations changes for webservice. This is because i have changed spring-jersey
to spring-web
.
add a comment |
I have not found any solution to the problem using spring-jersey
. So I have decided to use spring-web
.
Required changes I have made to project,
pom.xml
Remove spring-jersey
and add spring-web
,
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
package.json
"start": "ng serve --proxy-config proxy.conf.json",
"build": "ng build --base-href="./"",
Add proxy.conf.json file into base path of angular app,
"/api":
"target": "http://localhost:8080",
"secure": false
HackthonApplication.java
public class HackthonApplication extends SpringBootServletInitializer
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application)
return application.sources(HackthonApplication.class);
And there are some annotations changes for webservice. This is because i have changed spring-jersey
to spring-web
.
add a comment |
I have not found any solution to the problem using spring-jersey
. So I have decided to use spring-web
.
Required changes I have made to project,
pom.xml
Remove spring-jersey
and add spring-web
,
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
package.json
"start": "ng serve --proxy-config proxy.conf.json",
"build": "ng build --base-href="./"",
Add proxy.conf.json file into base path of angular app,
"/api":
"target": "http://localhost:8080",
"secure": false
HackthonApplication.java
public class HackthonApplication extends SpringBootServletInitializer
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application)
return application.sources(HackthonApplication.class);
And there are some annotations changes for webservice. This is because i have changed spring-jersey
to spring-web
.
I have not found any solution to the problem using spring-jersey
. So I have decided to use spring-web
.
Required changes I have made to project,
pom.xml
Remove spring-jersey
and add spring-web
,
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
package.json
"start": "ng serve --proxy-config proxy.conf.json",
"build": "ng build --base-href="./"",
Add proxy.conf.json file into base path of angular app,
"/api":
"target": "http://localhost:8080",
"secure": false
HackthonApplication.java
public class HackthonApplication extends SpringBootServletInitializer
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application)
return application.sources(HackthonApplication.class);
And there are some annotations changes for webservice. This is because i have changed spring-jersey
to spring-web
.
answered Apr 2 at 9:08
Kaustubh KhareKaustubh Khare
1,69016 silver badges30 bronze badges
1,69016 silver badges30 bronze badges
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55351303%2fdeploy-spring-boot-and-angular-7-application-using-war-into-tomcat-8-5%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
please post your index.html
– Ganesh Gudghe
Mar 26 at 6:56
@GaneshGudghe updated.
– Kaustubh Khare
Mar 26 at 7:01
Please check my answer it will solve your issue
– Ganesh Gudghe
Mar 26 at 7:02
can you try adding context path in your properties "server.servlet.context-path=/<<yourappname>>" ?
– Akhil S K
Mar 26 at 8:27
@AkhilSK I tried this one, but same 404 error.
– Kaustubh Khare
Mar 26 at 8:42