Is there a way to call React app in a Sring Boot (JSP file) and package them together - reactjs

I have tried multiple combinations with frontend-maven-plugin but getting
GET http://localhost:8081/demo/static/js/2.8d94841d.chunk.js net::ERR_ABORTED 404 this type of error on a View (JSP) where react page is included. I'm assuming it's due to an installation or page linking error while packaging.
my POM file snippet
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.7.6</version>
<configuration>
<workingDirectory>${frontend-src-dir}</workingDirectory>
<installDirectory>${project.build.directory}</installDirectory>
</configuration>
<executions>
<execution>
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<configuration>
<nodeVersion>v14.17.0</nodeVersion>
<npmVersion>6.14.13</npmVersion>
</configuration>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>install</arguments>
</configuration>
</execution>
<execution>
<id>npm run build</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>run build</arguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>generate-resources</phase>
<configuration>
<target>
<copy todir="target/Studio/resources/react">
<fileset dir="${project.basedir}/react/demo/build"/>
</copy>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
path to my react app - {frontend-src-dir}
JSP snippet with react app react app-
<jsp:include page="HeaderPage.jsp">
<jsp:param name="title" value="" />
</jsp:include>
<%#include file="/resources/react/index.html"%>
<jsp:include page="FooterPage.jsp">
<jsp:param name="title" value="" />
</jsp:include>
Project structure
Project structure image

Related

Apache cxf not generating sources in second plugin

I have a problem to generate sources 2 times from same wsdl but with different argument.
In effect, second cxf-codegen-plugin is completely ignored only because its the same url with the first cxf-codegen-plugin.
I tried to regroup them in one cxf-codegen-plugin but this not fixed the problem.
here is my code
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf.version}</version>
<executions>
<execution>
<id>generate-sources-test</id>
<phase>generate-sources</phase>
<configuration>
<wsdlOptions>
<wsdlOption>
<wsdl>test.wsdl</wsdl>
<extraargs>
<extraarg>-impl</extraarg>
<extraarg>-verbose</extraarg>
</extraargs>
<packagenames>
<packageName>com.test</packageName>
</packagenames>
<autoNameResolution>true</autoNameResolution>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf.version}</version>
<executions>
<execution>
<id>generate-sources-testtest</id>
<phase>generate-sources</phase>
<configuration>
<wsdlOptions>
<wsdlOption>
<wsdl>test.wsdl</wsdl>
<extraargs>
<extraarg>-b</extraarg>
<extraarg>${basedir}/src/main/resources/jaxb/mapping.xml</extraarg>
<extraarg>-xjc-Xts</extraarg>
<extraarg>-verbose</extraarg>
</extraargs>
<packagenames>
<packagename>com.testtest</packagename>
</packagenames>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.cxf.xjcplugins</groupId>
<artifactId>cxf-xjc-ts</artifactId>
<version>3.0.4</version>
</dependency>
</dependencies>
</plugin>

Allure Report - Environment not displaying Environment.properties/environment.xml

Trying to set up the environment table in the Allure report, tried to create environment.properties and the environment.xml, but its not generating the environment field. I see in the environment.json file, its empty.
Any idea?
Thanks.
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-allure-environment</id>
<phase>validate </phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/allure-results</outputDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>environment.properties</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
Why don't create the environment.properties from the code during the test?

How can I create multiple shared libraries with maven nar plugin?

How can I create multiple shared libraries with maven nar plugin? Here is a snippet from my pom.xml:
<plugin>
<groupId>com.github.maven-nar</groupId>
<artifactId>nar-maven-plugin</artifactId>
<version>3.5.1</version>
<extensions>true</extensions>
<executions>
<execution>
<id>compile-C-shared-lib</id>
<phase>compile</phase>
<goals>
<goal>nar-compile</goal>
</goals>
</execution>
<execution>
<id>generate_c_header_from_java</id>
<phase>generate-sources</phase>
<goals>
<goal>nar-javah</goal>
</goals>
</execution>
</executions>
<configuration>
<libraries>
<library>
</library>
</libraries>
</configuration>
</plugin>
I can create a shared library with this pom. But I want to build two libraries. From pack of source files. How can I do this?

Not able to run Apache CXF Codegen Plugin

Iam not able to run the apache CXF codegen plugin thats in my pom.xml file. While running the build im getting the following error
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>2.7.3</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>${project.build.directory}/generated/cxf</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/src/main/resources/wsdl/activateDevice.wsdl</wsdl>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
Im getting the following error
Failed to execute goal org.apache.cxf:cxf-codegen-plugin:2.7.3:wsdl2java (generate-sources) on project dealer: org/apache/velocity/context/Context: org.apache.velocity.context.Context -> [Help 1]
Thanks for the help
Try this one:
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>2.7.3</version>
<dependencies>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-bindings-soap</artifactId>
<version>2.7.3</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>generate-jaxb</id>
<phase>generate-sources</phase>
<configuration>
<additionalJvmArgs>-Dfile.encoding=UTF8</additionalJvmArgs>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/src/main/resources/wsdl/activateDevice.wsdl</wsdl>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
This one worked for me
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf.version}</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>${project.build.directory}/generated/cxf</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>src/main/resources/wsdl/resourceservice1.wsdl</wsdl>
<bindingFiles>
<bindingFile>src/main/resources/wsdl/binding.xml</bindingFile>
</bindingFiles>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>${jaxb.version}</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-xjc</artifactId>
<version>${jaxb.version}</version>
</dependency>
</dependencies>
</plugin>

liquibase using maven with two databases

i have the following structure to run one database from maven:
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-plugin</artifactId>
<version>1.9.5.0</version>
<executions>
<execution>
<phase>process-resources</phase>
<configuration>
<changeLogFile>src/main/resources/db.changelog.xml</changeLogFile>
<driver>com.mysql.jdbc.Driver</driver>
<url>jdbc:mysql://localhost:3306/charm</url>
<username>***</username>
<password>***</password>
</configuration>
<goals>
<goal>update</goal>
</goals>
</execution>
</executions>
</plugin>
now i want to run another database in the same server with the name charm2. i tried this:
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-plugin</artifactId>
<version>1.9.5.0</version>
<executions>
<execution>
<phase>process-resources</phase>
<configuration>
<changeLogFile>src/main/resources/db.changelog.xml</changeLogFile>
<driver>com.mysql.jdbc.Driver</driver>
<url>jdbc:mysql://localhost:3306/charm</url>
<username>***</username>
<password>***</password>
</configuration>
<goals>
<goal>update</goal>
</goals>
</execution>
<execution>
<phase>process-resources</phase>
<configuration>
<changeLogFile>src/main/resources/db.changelog.xml</changeLogFile>
<driver>com.mysql.jdbc.Driver</driver>
<url>jdbc:mysql://localhost:3306/charm2</url>
<username>***</username>
<password>***</password>
</configuration>
<goals>
<goal>update</goal>
</goals>
</execution>
</executions>
</plugin>
and it does not work. does anyone know how to solve this?
Perhaps you could try giving an <id> to each <execution>. Something like
...
<execution>
<id>charm</id>
<phase>process-resources</phase>
<configuration>
...
</execution>
<execution>
<id>charm2</id>
<phase>process-resources</phase>
<configuration>
...
</execution>
...
If this does not work, you could update your question with the full stacktrace specifying the exact line that maven fails to validate the pom.

Resources