Spring Boot 1.5.9 - Jaxb2Marshaller - spring

Trying to learn Spring Boot. Taking existing Spring application and rebuilding it in a new boot project. One of my clasess relies upon a dependency org.springframework -> spring-oxm which is for the Jaxb2Marshaller.
In my Spring Boot project when I add this dependency
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-oxm</artifactId>
<version>3.2.2.RELEASE</version>
</dependency>
When I add the above to my POM it never pulls the jar in so I cannot import the Jaxb2Marshaller. I believe Spring Boot logic is keeping this from being pulled in because of the version. I tried other versions, but no luck. What is the proper way to pull in this spring dependency with the right version?

Related

Spring: spring-data-mongodb or spring-boot-starter-data-mongodb

Which's the difference between
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb</artifactId>
</dependency>
and,
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
I'm developing an spring boot service.
spring-boot-starter-data-mongodb contains configuration classes for Spring Boot. It also includes the spring-data-mongodb library so you would only need to include the start in your boot app:
https://search.maven.org/artifact/org.springframework.boot/spring-boot-starter-data-mongodb/2.0.5.RELEASE/jar
spring-boot-starter-data-mongodb is a spring boot starter pom. For more information on starters:
spring-boot-starters
Dependency management is a critical aspects of any complex project. And doing this manually is less than ideal; the more time you spent on it the less time you have on the other important aspects of the project.
Spring Boot starters were built to address exactly this problem. Starter POMs are a set of convenient dependency descriptors that you can include in your application. You get a one-stop-shop for all the Spring and related technology that you need, without having to hunt through sample code and copy paste loads of dependency descriptors.

maven dependencies for writing Spring AOP programs?

I am trying to learn Spring AOP programming using Spring 5. I am going through online materials.
I came to know that AOP is a concept, similar to OOP; and with AOP,OOPs becomes more powerful.
Now, I am trying to do some hands-on coding for AOP with Spring framework, version 5.
I am going to use maven as the build tool.
I am not clear on what are the various dependencies that we have to use in pom.xml, for example do we need to use: spring-aop , spring-aspects, aspectjetc.
Can anyone guide me what are the various maven dependencies that we have to add in pom.xml to be able to write using maven tool, Spring 5 AOP programs?
Thanks in advance
Its very simple, in order to work spring With AOP, You need aspectjweaver Library existe on the classpath of your application (version 1.6.8 or later).use this dependency to achieve that
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.8.13</version>
</dependency>
As they mention in docs
To enable #AspectJ support with Java #Configuration add the
#EnableAspectJAutoProxy annotation:
You can find more info here
The only spring dependency to make something work with AOP is the famous spring-context :
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.0.2.RELEASE</version>
</dependency>
If you want a working example check my project in github which contains basic Maven AOP example based on spring
If you are trying to use CGLIB proxies in Spring without Spring Boot (and any starter dependencies of Spring Boot) then you need aspectjweaver besides spring-context, spring-aop dependencies.
Be careful not to add any of the dependencies if they already exist among your Maven dependencies - adding the same dependency with multiple versions may lead to a failing build.

Which one should I use among spring boot, spring BOM and spring IO?

I tried to read documents regarding Spring BOM, Spring Boot and Spring IO. But there is no clarification on, how we should use them together or not?
In my project, we already have our own Parent POM, So I can’t use as parent them but all they have alternative way to use, Like below by defining dependency management
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-framework-bom</artifactId>
<version>${org.springframework-version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<!-- Import dependency management from Spring Boot -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>1.2.5.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
Spring BOM, Spring Boot and Spring IO resolve version required for you
So what is exactly difference between them? Which one should I prefer? And in Which condition?
The Spring Framework bom provides dependency management for all of Spring Framework's modules. The Spring Boot bom is a superset of this. In addition to providing dependency management for Spring Framework, it also provides dependency management for Spring Boot's modules, a number of other Spring projects, and various third-party dependencies which Spring Boot supports. The Spring IO Platform bom is, in turn, a superset of the Spring Boot bom. The main change is that it adds dependency management for all of the Spring projects' dependencies.
If you're not using Spring Boot, or if you want to use your own dependency management, then you may want to use the Spring Framework bom . If you're using Spring Boot, or you want some help with dependency management, then you should choose between using Spring Boot's bom or the Spring IO Platform bom. The main choice here is how close to the leading edge you want to be. If you favour being up-to-date then use the Spring Boot bom. If your project is more conservative and backwards compatibility is of paramount importance, then you should consider using the Spring IO platform bom.

Error when creating new Spring MVC project in IntelliJ: invalid item 'Maven: org.springframework:spring-test-mvc:1.0.0.M2

Using IntelliJ IDEA 13.1.4 to create a new project with Spring MVC and "Create project from template" checked, I get the error message below in the project structure.
Anyone know why, and whether I should worry about it?
Module 'Test': invalid item 'Maven: org.springframework:spring-test-mvc:1.0.0.M2' in the dependencies list
Hmm... What version of Spring is the template project using?
From Spring 3.2 and onwards the spring-test-mvc dependency was merged into spring-test dependency.
So for anything using Spring 3.2 onwards you only need:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<scope>test</scope>
</dependency>
Also, It might be worth looking at the Spring platform-bom

Maven : Spring 4 + Spring Security

Can you explain to me how to properly build a web app with Spring? I know that the latest version of Spring framework is 4.0.0.RELEASE, but the latest version of Spring Security is 3.2.0.RELEASE, and it depends on spring 3.2.6... maybe i'm wrong :)
How can I integrate it with Maven?
Can I use Spring 4 or must I use the previous version?
What is the proper way?
If it`s not hard for you could you show me you pom.xml?
You should be fine using Spring 4. As described in the documentation:
"Spring Security builds against Spring Framework 3.2.6.RELEASE, but is also tested against Spring Framework 4.0.0.RELEASE. This means you can use Spring Security 3.2.0.RELEASE with Spring Framework 4.0.0.RELEASE."
They go on to describe strategies for integrating Spring 4 with Spring Security in your project. Like this one:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-framework-bom</artifactId>
<version>4.0.0.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

Resources