I am working with:
- Spring Framework - 5.0.4.RELEASE
- Gradle - 4.7
- Thymeleaf - 3.0.9.RELEASE
All the project is based with multi modules.
Among many modules I have these two:
-
thymeleaf-02-controller
: all about the@Controller
s -
thymeleaf-02-web
: all about the.html
files (css, js too)
Yes, is important have separated all about the .java files from all about the web files (.html, .js etc …)
About the Gradle
their configurations:
In the thymeleaf-02-web
module exists:
apply plugin: 'war'
project(':thymeleaf-02-web') {
description 'Web (HTML, JS, CSS)'
dependencies {
exportedProjects.each{
if("$it"!=":thymeleaf-02-web")
compile project("$it")
}
}
webAppDirName = 'src/main/webapp'
war {
version=''
baseName = warBaseName
}
...
}
In the thymeleaf-02-controller
module exists:
project(':thymeleaf-02-controller') {
description 'Web - Controller'
dependencies {
compile project(':thymeleaf-02-infrastructure')
compile project(':thymeleaf-02-service-api')
...
//Omicron:
//What is the correct approach?
//The code shown below does not work
testCompile project(':thymeleaf-02-web')
testRuntime project(':thymeleaf-02-web')
testRuntime fileTree(dir: "/WEB-INF/view/html", include: '*.html')
}
}
Note: If the multi module project is exported to a .war
file all work fine, it of course in Tomcat
. Thus the runtime
environment is stable
The problem is about the testing
environment, it just for the thymeleaf-02-controller
module. Thus always appears:
[main] ERROR org.thymeleaf.TemplateEngine -
[THYMELEAF][main] Exception processing template "persona/deleteOne":
An error happened during template parsing
(template: "ServletContext resource
[/WEB-INF/view/html/persona/deleteOne.html]")
org.thymeleaf.exceptions.TemplateInputException:
An error happened during template parsing
(template: "ServletContext resource
[/WEB-INF/view/html/persona/deleteOne.html]")
...
Caused by: java.io.FileNotFoundException:
Could not open ServletContext resource
[/WEB-INF/view/html/persona/deleteOne.html]
...
The error is clear, thanks to FileNotFoundException
What is the correct approach to resolve the Omicron
section shown above?.
Therefore only for testing the thymeleaf-02-controller
module is not able to refer/reach/see/use all the .html
files located in the /WEB-INF/view/html/..
directory from the thymeleaf-02-web
module.
One thing that is curious is that must exists at least one .java
file in the src/main/java
Source Folder in the thymeleaf-02-web
module to see in the thymeleaf-02-controller
module the thymeleaf-02-web
how a dependency through the Project and External Dependencies
. Otherwise thymeleaf-02-web
does not appear how a dependency.