mvn:spring-boot run is not working for Spring Boot Ear package - spring

Have created Spring Boot EAR project
parent
-- ear
-- war
Ear
--war
Go to war spring boot project inside parent project and execute mvn:springboot run throws following error. If I create individual spring boot war application with no ear package, then mvn:springboot run command is working.
org.apache.maven.plugin.prefix.NoPluginFoundForPrefixException: No plugin found for prefix 'spring' in the current project and in the plugin groups [org.apache.maven.plugins, o
at org.apache.maven.plugin.prefix.internal.DefaultPluginPrefixResolver.resolve (DefaultPluginPrefixResolver.java:95)
at org.apache.maven.lifecycle.internal.MojoDescriptorCreator.findPluginForPrefix (MojoDescriptorCreator.java:266)
at org.apache.maven.lifecycle.internal.MojoDescriptorCreator.getMojoDescriptor (MojoDescriptorCreator.java:220)
at org.apache.maven.lifecycle.internal.DefaultLifecycleTaskSegmentCalculator.calculateTaskSegments (DefaultLifecycleTaskSegmentCalculator.java:104)

Related

How to build and deploy a multiple module Spring Boot maven app on External Tomcat container with Jenkins

My Spring boot app is a multi-module app and have 3 modules
models
service-impl
service-api
Each module has it own pom.xml with packaging type jar.
Parent pom.xml have packaging type pom
I am able to build and deploy it to integrated server on my local system but not sure how to build and deploy it via Jenkins Job on external tomcat server.
Is it possible to deploy them together in single war package or I have to build and deploy each service separately.

How to ship a Spring Boot app from a Gradle Multi Build project?

Let's say I have a Gradle Multi Project with 3 subprojects, 2 Spring Boot projects (auth and profile) and 1 Library project (commons).
The 2 Spring Boot projects include a dependency on the Library project: implementation project(":commons")
Actually, to run the 2 Spring Boot projects, I have to run this from the parent project:
gradlew auth:bootRun
gradlew profile:bootRun
If I run gradlew bootRun only, from each Spring Boot subproject, I get the Error like the :commons Library project is not found in the root project, which makes sense, because the :commons project is included only in the parent's settings.gradle file.
I have to push each Spring Boot subproject individually to Heroku.
How should I manage ?
I finally got it, just add this in each subproject's settings.gradle file, then build:
include ":commons"
project(':commons').projectDir = new File('../commons')

Use of spring-boot-maven-plugin

While creating a spring boot project I define property in pom.xml as <packaging>war</packaging> with which I can create a war and thereafter deploy the war into server maybe tomcat or WAS.
But I came across a plugin named spring-boot-maven-plugin whose documentation states that it's use is to package executable jar or war archives and run an application in-place.
My query is why do we need this at all ?
If my packaging can tell me what to create and then can deploy it to run, what is the used of this plugin.
I am trying to understand a new project so wanted to be sure that every line makes sense
The maven plugin will create an "executable" archive. In the case of the war packaging, you would be able to execute your app with java -jar my-app.war. If you intend to deploy your Spring Boot application in an existing Servlet container, then this plugin is, indeed, not necessary.
The maven plugin does more things like running your app from the shell or creating build information.
Check the documentation
The Spring Boot Maven Plugin provides Spring Boot support in Apache Maven, letting you package executable jar or war archives and run an application “in-place”.
Refer this - https://www.javaguides.net/2019/02/use-of-spring-boot-maven-plugin-with.html

what is reason the spring boot application doesn't read application.properties file?

i have a maven project then i'm manually added a 'src/main/resources' directory and application.properties but it can't read the application.properties file;
How can i convert my maven project to spring boot project ?
You need to say your IDE that src/main/resources is a source folder.
Try a maven plugin (e.g. for Eclipse http://maven.apache.org/plugins-archives/maven-eclipse-plugin-2.8/eclipse-mojo.html),
do it manually
start your application using the maven spring-boot plugin
mvn spring-boot:run
http://docs.spring.io/spring-boot/docs/current/maven-plugin/usage.html

Spring Boot Initializr: Maven project or Maven POM?

I want to set up a Spring Boot project using the Spring Initializr (https://start.spring.io) but I was wondering about the difference in the project type you can choose between: Maven Project or Maven POM?
What is exactly the difference between these two types?
Maven POM creates only the pom.xml file.
Maven Project creates the pom.xml file and a sample project including src folder:
> src:
> main:
> java:
> com.example:
Application.java
> resources:
application.properties
> test:
> java:
> com.example:
ApplicationTest.java
> pom.xml
Maven Project is the type which we use to create a common Spring Boot application. It seems Maven POM is for downloading build scripts only.
Basic difference that you even experience it by selecting the maven project option and say download, you get a maven which includes sample spring boot application
Other case you have existing project and want to add spring boot then you can simply get the configuration to include spring boot artifacts

Resources