Thymeleaf Configuration - Not able to import org.thymeleaf.spring4.* - spring-boot

I am using Thymeleaf in my spring-boot web-application, and I am trying to use the already provided functionalities of the Thymelief for a Spring Boot project. But, I am not able to import the org.thymeleaf.spring4.* - actually, spring4 is not recognized at all. I am using Thymeleaf 3.0.11.
Actually, in my project, gradle is used as a build automation tool, and Thymeleaf is added as in the following (in a multi-module Spring Boot application, and this gradle file corresponds to the module where the Thymeleaf template engine is configured):
configurations.all {
resolutionStrategy {
...
dependencySubstitution {
...
substitute module('org.thymeleaf:thymeleaf') with module('org.thymeleaf:thymeleaf:3.0.11.RELEASE')
}
}
}
I would appreciate any idea about the reason of this is happening?

Ensure that you have added dependency in pom.xml
<!-- https://mvnrepository.com/artifact/org.thymeleaf/thymeleaf-spring4 -->
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf-spring4</artifactId>
<version>3.0.11.RELEASE</version>
</dependency>

Related

Maven cannot find dependency from imported jar file

I have a service library that contains the Spring Starter Web dependency, e.g.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
I name this service library "spring-boot-starter-service" and intend to use it in another API project, and this API project does not contain Spring Starter Web.
After making changes to this service library, I use maven install to create a jar file (and I can see that the code changes were reflected) in classes under /target directory
I use the following dependency in the API project, hoping to import the service library and its Spring Starter Web
<dependency>
<groupId>com.example.spring</groupId>
<artifactId>spring-boot-starter-service</artifactId>
<scope>system</scope>
<version>1.0.40</version>
<systemPath>
/Users/xxxxxx/IdeaProjects/spring-boot-starter-service/target/spring-boot-starter-services-1.0.40-SNAPSHOT.jar
</systemPath>
</dependency>
Unfortunately, I was not able to successfully import the Spring Starter Web (as well as other dependencies in the service library) using the above dependency in pom.xml
Anyone knows what I missed? Thanks

spring boot project as dependency inside another spring-boot project

I have a spring boot project(project-lib) which I am including as maven dependency in another spring boot project(my-project).
now the project-lib uses logback and i want to exclude the logback dependency in my-project.
Also currently project-lib is defined as dependency with classifier jar-with-dependencies
Is it possible to define project-lib as normal dependency instead of jar-with-dependencies.
I tried to define it as normal dependency assuming it will download all the required dependencies as project-lib/pom.xml has already defined the required dependencies to run project-lib but it did not work that way.
part of pom.xml of my-project
<dependency>
<groupId>com.xyz/groupId>
<artifactId>project-lib</artifactId>
<version>0.0.4-SNAPSHOT</version>
<classifier>jar-with-dependencies</classifier>
</dependency>

how do I set up mocking using mockito in netbeans in a java maven project?

how to I set up mocking using mockito in netbeans in a java maven project? I understand mocking but cant find mockito files in the maven repo
import static org.mockito.Mockito.*;
If you're manually setting up your pom.xml in NetBeans, I think this is what you want:
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>1.10.19</version>
</dependency>
I'm using Mockito in a Java project right now, but fair warning, I'm using Ivy for dependency management, not Maven.
http://mvnrepository.com/artifact/org.mockito/mockito-core/1.10.19

Maven/Spring multi module project logging

I am trying to convert a huge maven/spring webapp to a multi module project.
Logging is implemented with this method (http://docs.spring.io/spring/docs/4.0.2.RELEASE/spring-framework-reference/htmlsingle/#overview-logging-slf4j) in the huge project. What is the correct way to do this in a maven multi module project? Is it necessary to define this in every pom.xml or only in my main pom.xml.
My main pom.xml defines this dependency:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-framework-bom</artifactId>
<version>4.0.2.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Is it possibly to exclude commons-logging on this dependency?
Update:
The project structure:
Parent Project:
Project A: jar
Project B: jar
Project C: war
Project D: war
All projects using parts of the Spring framework. I am using SLF4J for logging. What is the correct way for including SLF4J in this project setup with maven?
It should only be necessary to exclude commons-logging from "spring-core", but some third-party libraries also include it, so that isn't always enough. You could try using Spring Boot starters to build up your Spring dependencies (even if you aren't using other Boot features), since the default logging system is logback and commons-logging has been carefully excluded.

Eclipse (STS) MVC 3.0.5 + Tiles 2.2.2 project dependency management issue

For some reason I cannot use maven or gradle dependecy management. I am trying to use Tiles with Spring MVC, I get the following Exception on tcserver startup:
java.lang.NoClassDefFoundError: org/apache/tiles/startup/BasicTilesInitializer
Here is my dependencies folder:
Also Eclipse points out this Error in my layout.jsp
The tag handler class for
"tiles:insertAttribute" (org.apache.tiles.jsp.taglib.InsertAttributeTag) was not found on the Java Build
Path
Can anyone point out what am I missing?
You put the SOURCE jars in you project lib folder. But you need to use the normal once with the compiled classes.
tiles-core-2.2.2.jar instead of tiles-core-2.2.2-sources.jar
If you use maven to manage dependency then add below to your pom.
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-core</artifactId>
<version>2.2.2</version>
</dependency>
Else Download following jars and add it to /WEB-INF/lib
tiles-core.2.2.2.jar
tiles-api.2.2.2.jar
and also add this transitive dependency as tiles use on Slf4j
slf4j-jdk14.1.5.8.jar

Resources