Difference between the jars for spring web services - spring

I have just started learning on spring webservices but when I search for the tutorials in some examples they added the following dependency for springwscore and in some examples the following dependency for spring-boot-starter-ws.which jar sholud be used and why spring has two jars for spring web services.

The easiest way would be including dependency by adding Spring Ws Core to Maven pom.xml file (if you are using Maven)
<dependencies>
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-ws-core</artifactId>
<version>2.4.0.RELEASE</version>
</dependency>
</dependencies>

Related

Spring initializr not showing activiti dependency

I am trying to create spring-boot project for activiti but it is not showing activiti dependency.
How can I know that with which springboot version,activiti version is mapped?
Spring Initializr
If you're refererring to Activiti, this is not included in the Spring Initializr so you will need to include this manually yourself.
Go through the Spring Initializr setup
Generate and download the code to your machine
Add the Activiti dependency to your POM or Gradle file:
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-spring-boot-starter-basic</artifactId>
<version>6.0.0</version>
</dependency>
Add the H2 dependency for database (don't use this in production):
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.183</version>
</dependency>
I haven't used Activiti before but this is based on their Spring Boot documentation.
Spring boot 2 doesn't have activiti anymore.
Manually need to add activiti dependency.
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-spring-boot-starter</artifactId>
<version>7.0.0.Beta1</version>
</dependency>

How to deploy spring boot framework in tomcat

I have an application that dynamically generates several web application (war files) with the same dependencies (spring boot, kafka, etc.) .my question is how I can put all these dependencies in Tomcat to reduce the size of the war files and after in my pom.xml I write for example.
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<scope>provided</scope>
</dependency>
One idea I can think of is to add the common jars to Tomcat/lib/SharedFolder and include that under shared.loader in catalina.properties and then Add the jars as provided dependencies. I can see you have already added the provided tag.
I think that will work. I haven't tried it in a sample application but I remember helping my friend do something similar to what I described above.
Hope it helps

Autoconfiguation excluded but embedded servlet container is still being used

I've followed all the steps mentioned in the documentation to enable the traditional war deployment for spring boot app i.e excluded the EmbeddedServletContainerAutoConfiguration from the #EnableAutoConfiguration and I only have one such instance. Also extended SpringBootServletInitializer and make sure the packaged war doesnt have any tomcat starter dependency. Also ran the spring boot report and confirmed the EmbeddedServletContainerAutoConfiguration is in the exclusion list.
Apart from all the changes when I deploy the war it is still creating a embedded application context with embedded servlet contatiner.
What did I miss and what other areas can I inspect ? Spring boot version 1.5.13.
>
Hi Veeram,
We do not need to exclude the AutoConfiguration-classes, but excluding the tomcat dependency is needed.
You need to do is omit tomcat starter dependency from pom.xml. It gets pulled from spring-boot-starter-web as a transitive dependency. So, you need to add exclusion for it:
<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>
Now, as you are using <packaging>war</packaging> and using SpringBootServletInitializer, we would need servlet-api dependency on the classpath.
So, add the servlet dependency to your pom.xml
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
Hope this helps!

My Jersey Spring Boot 1.5.2 project doesn't recognize FormDataMultiPart

I tried to add FormDataMultiPart to my Jersey Spring Boot project. I am using Spring Boot 1.5.2 and the Spring Boot Jersey Starter.
I tried adding the full import org.glassfish.jersey.media.multipart.FormDataMultiPart, but it is not found.
It looks like spring-boot-starter-jersey Maven dependency does not include jersey-media-multipart. You need to add it to your pom.xml. On the other hand, Spring Boot does define a jersey.version property so you can use that to keep the versions in sync.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jersey</artifactId>
</dependency>
<!-- Multipart not included in Spring Boot. jersey.version defined by Spring Boot. -->
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-multipart</artifactId>
<version>${jersey.version}</version>
</dependency>
Once you add the jersey-media-multipart dependency to Maven, the FormDataMultiPart class can be found.

Spring Boot with Spring HATEOAS Maven conflicts

It seems when I add the dependency for the spring-hateoas
<groupId>org.springframework.hateoas</groupId>
<artifactId>spring-hateoas</artifactId>
<version>0.13.0.RELEASE</version>
The Class below is no longer available on the classpath
org.springframework.web.bind.annotation.RestController;
I have tried to exclude various dependencies for the spring-hateoas but the APP no longer runs.
Has anyone had any luck running spring-hateoas within spring boot.
Absolutely no problem whatsoever. The #RestController annotation is still available and you shouldn't need to do any exclusion.
In case it helps, I'm currently using version 1.0.2 of Spring Boot:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.0.2.RELEASE</version>
</parent>
spring-boot-starter-web provides the #RestController:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
I don't define an explicit version for spring-hateoas in my pom.xml, but my build is pulling in 0.9.0.RELEASE:
<dependency>
<groupId>org.springframework.hateoas</groupId>
<artifactId>spring-hateoas</artifactId>
</dependency>
As a side note, I can see from the Eclipse POM editor, that Spring HATEOAS is defining dependencies on Spring 3.2.7. However the spring-boot-starter-parent project manages the versions up to 4.0.3. Can you see what version of Spring you are getting? Have you perhaps not used the spring-boot-parent as a parent project?

Resources