-
Notifications
You must be signed in to change notification settings - Fork 41.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hard-coded uses of src/main/webapp preclude any other project layouts from working #23829
Comments
Looking at the hits you found, most of them are in integration/smoke tests for the framework itself. There are 2 that might be troublesome (well actually 1 as the other is configurable). The one in Update (1) Not sure if the same logic should be applied in the Update (2) @Bean
public TomcatContextCustomizer docBaseCustomizer() {
return new TomcatContextCustomizer() {
public void customize(Context context) {
File root = new File("source/production/webapp");
if (root.exists() && root.isDirectory()) {
context.setDocBase(root.getAbsolutePath());
}
}
};
} The drawback is that this adds another location to set the proper Update (3) Setting the value would only need to be done if the passed in path is a directory and exists (basically the same check that is done in the |
See #12859 for more background |
If For configuring said servlet container, I support the suggestion to make the webroot(s) configurable using a property. The Spring Boot Maven and Gradle plugins could then set this property to the correct value when executing the application or its tests. For jar-based applications, it might also be a nice feature to be able to configure a webroot. #17233 might add some more background about what is (or should be) considered as web root under different deployment and packaging options. |
I did a bit of digging on this one and I think we'll perhaps need to revisit the fix for #12805 (solved by PR #12859 in Boot 1.5). Perhaps we can make the It's a bit tricky because currently |
I'll outline a description of the precise problem here, but if you're looking for a deep-dive on exactly how I arrived here, including sample code, take a look at this Stack Overflow post.
In Java Maven projects, the "default" layout (and what most projects use) is
src/main/java
,src/main/resources
,src/test/java
, andsrc/test/resources
. However, those are only defaults, and nothing prevents a team from using a different layout. The following configuration supports the layoutsource/production/java
,source/production/resources
,source/test/java
, andsource/test/resources
:The
maven-war-plugin
has a similar default: It looks for web application resources insrc/main/webapp
. However, once again, this is just a default, and it can be configured using<warSourceDirectory>
:A problem arises in the fact that Spring Boot hard-codes
src/main/webapp
in several places throughout the code, which makes it impossible to use a layout which uses a different directory structure for web resources.I've contributed to Spring before (it's been many years), so I'm willing to work on a pull request to address this problem, but I need some guidance first. I need to know things like: Where would this get configured (
spring-boot-maven-plugin
? somewhere else?)? How do I get that configuration in those places in code? Perhaps other things that I don't yet know that I need to know.The text was updated successfully, but these errors were encountered: