参考源代码:org.springframework.boot.context.embedded.AbstractEmbeddedServletContainerFactory
private static final String[] COMMON_DOC_ROOTS = { "src/main/webapp", "public",
"static" };
/**
* Returns the absolute document root when it points to a valid folder, logging a
* warning and returning {@code null} otherwise.
* @return the valid document root
*/
protected final File getValidDocumentRoot() {
File file = getDocumentRoot();
// If document root not explicitly set see if we are running from a war archive
file = file != null ? file : getWarFileDocumentRoot();
// If not a war archive maybe it is an exploded war
file = file != null ? file : getExplodedWarFileDocumentRoot();
// Or maybe there is a document root in a well-known location
file = file != null ? file : getCommonDocumentRoot();
if (file == null && this.logger.isDebugEnabled()) {
this.logger.debug("None of the document roots "
+ Arrays.asList(COMMON_DOC_ROOTS)
+ " point to a directory and will be ignored.");
}
else if (this.logger.isDebugEnabled()) {
this.logger.debug("Document root: " + file);
}
return file;
}
项目发布目录原结构
.
./lib
./lib/jandex-1.1.0.Final.jar
./lib/hibernate-commons-annotations-4.0.5.Final.jar
./lib/spring-aop-4.1.7.RELEASE.jar
./lib/sslext-1.2-0.jar
./lib/antlr-2.7.7.jar
./lib/spring-data-commons-1.9.3.RELEASE.jar
./lib/spring-boot-actuator-1.2.5.RELEASE.jar
./lib/tomcat-juli-7.0.59.jar
./lib/struts-taglib-1.3.8.jar
./lib/slf4j-api-1.7.12.jar
./lib/jcl-over-slf4j-1.7.12.jar
./lib/aspectjrt-1.8.6.jar
./lib/commons-digester-2.1.jar
./lib/dom4j-1.6.1.jar
./lib/commons-chain-1.1.jar
./lib/velocity-tools-2.0.jar
./lib/spring-jdbc-4.1.7.RELEASE.jar
./lib/spring-expression-4.1.7.RELEASE.jar
./lib/hibernate-jpa-2.1-api-1.0.0.Final.jar
./lib/spring-boot-starter-web-1.2.5.RELEASE.jar
./lib/spring-tx-4.1.7.RELEASE.jar
./lib/mockito-core-1.10.8.jar
./lib/spring-boot-starter-data-jpa-1.2.5.RELEASE.jar
./lib/spring-orm-4.1.7.RELEASE.jar
./lib/struts-tiles-1.3.8.jar
./lib/spring-boot-autoconfigure-1.2.5.RELEASE.jar
./lib/tomcat-embed-el-7.0.59.jar
./lib/jboss-logging-3.1.3.GA.jar
./lib/tomcat-embed-websocket-7.0.59.jar
./lib/javax.transaction-api-1.2.jar
./lib/spring-boot-starter-tomcat-1.2.5.RELEASE.jar
./lib/spring-webmvc-4.1.7.RELEASE.jar
./lib/spring-boot-starter-log4j-1.2.5.RELEASE.jar
./lib/hibernate-entitymanager-4.3.10.Final.jar
./lib/jul-to-slf4j-1.7.12.jar
./lib/commons-beanutils-1.9.2.jar
./lib/spring-boot-legacy-1.0.1.RELEASE.jar
./lib/velocity-1.7.jar
./lib/commons-validator-1.3.1.jar
./lib/spring-context-4.1.7.RELEASE.jar
./lib/struts-core-1.3.8.jar
./lib/aopalliance-1.0.jar
./lib/classmate-1.0.0.jar
./lib/oro-2.0.8.jar
./lib/junit-4.11.jar
./lib/spring-boot-starter-velocity-1.2.5.RELEASE.jar
./lib/jackson-core-2.4.6.jar
./lib/validation-api-1.1.0.Final.jar
./lib/jboss-logging-annotations-1.2.0.Beta1.jar
./lib/spring-data-jpa-1.7.3.RELEASE.jar
./lib/snakeyaml-1.14.jar
./lib/tomcat-embed-logging-juli-7.0.59.jar
./lib/commons-lang-2.6.jar
./lib/ehcache-2.8.5.jar
./lib/hamcrest-library-1.3.jar
./lib/commons-io-2.4.jar
./lib/spring-web-4.1.7.RELEASE.jar
./lib/spring-boot-1.2.5.RELEASE.jar
./lib/spring-context-support-4.1.7.RELEASE.jar
./lib/spring-boot-starter-aop-1.2.5.RELEASE.jar
./lib/objenesis-2.1.jar
./lib/spring-core-4.1.7.RELEASE.jar
./lib/jackson-annotations-2.4.6.jar
./lib/jackson-databind-2.4.6.jar
./lib/hibernate-validator-5.1.3.Final.jar
./lib/spring-boot-starter-jdbc-1.2.5.RELEASE.jar
./lib/hamcrest-core-1.3.jar
./lib/tomcat-embed-core-7.0.59.jar
./lib/spring-aspects-4.1.7.RELEASE.jar
./lib/spring-test-4.1.7.RELEASE.jar
./lib/spring-beans-4.1.7.RELEASE.jar
./lib/commons-collections-3.2.1.jar
./lib/log4j-1.2.17.jar
./lib/aspectjweaver-1.8.6.jar
./lib/javassist-3.18.1-GA.jar
./lib/spring-boot-starter-test-1.2.5.RELEASE.jar
./lib/hibernate-core-4.3.10.Final.jar
./lib/xml-apis-1.0.b2.jar
./lib/spring-boot-starter-1.2.5.RELEASE.jar
./lib/slf4j-log4j12-1.7.12.jar
./lib/tomcat-jdbc-7.0.59.jar
./lib/spring-boot-starter-actuator-1.2.5.RELEASE.jar
./lib/ojdbc7-12.1.0.1.0.jar
./mainweb.jar
当前目录下,添加static目录,并在下面创建WEB-INF,将tools.xml拷贝到该目录下。
新的目录结构
./lib
./lib/jandex-1.1.0.Final.jar
./lib/hibernate-commons-annotations-4.0.5.Final.jar
./lib/spring-aop-4.1.7.RELEASE.jar
./lib/sslext-1.2-0.jar
./lib/antlr-2.7.7.jar
./lib/spring-data-commons-1.9.3.RELEASE.jar
./lib/spring-boot-actuator-1.2.5.RELEASE.jar
./lib/tomcat-juli-7.0.59.jar
./lib/struts-taglib-1.3.8.jar
./lib/slf4j-api-1.7.12.jar
./lib/jcl-over-slf4j-1.7.12.jar
./lib/aspectjrt-1.8.6.jar
./lib/commons-digester-2.1.jar
./lib/dom4j-1.6.1.jar
./lib/commons-chain-1.1.jar
./lib/velocity-tools-2.0.jar
./lib/spring-jdbc-4.1.7.RELEASE.jar
./lib/spring-expression-4.1.7.RELEASE.jar
./lib/hibernate-jpa-2.1-api-1.0.0.Final.jar
./lib/spring-boot-starter-web-1.2.5.RELEASE.jar
./lib/spring-tx-4.1.7.RELEASE.jar
./lib/mockito-core-1.10.8.jar
./lib/spring-boot-starter-data-jpa-1.2.5.RELEASE.jar
./lib/spring-orm-4.1.7.RELEASE.jar
./lib/struts-tiles-1.3.8.jar
./lib/spring-boot-autoconfigure-1.2.5.RELEASE.jar
./lib/tomcat-embed-el-7.0.59.jar
./lib/jboss-logging-3.1.3.GA.jar
./lib/tomcat-embed-websocket-7.0.59.jar
./lib/javax.transaction-api-1.2.jar
./lib/spring-boot-starter-tomcat-1.2.5.RELEASE.jar
./lib/spring-webmvc-4.1.7.RELEASE.jar
./lib/spring-boot-starter-log4j-1.2.5.RELEASE.jar
./lib/hibernate-entitymanager-4.3.10.Final.jar
./lib/jul-to-slf4j-1.7.12.jar
./lib/commons-beanutils-1.9.2.jar
./lib/spring-boot-legacy-1.0.1.RELEASE.jar
./lib/velocity-1.7.jar
./lib/commons-validator-1.3.1.jar
./lib/spring-context-4.1.7.RELEASE.jar
./lib/struts-core-1.3.8.jar
./lib/aopalliance-1.0.jar
./lib/classmate-1.0.0.jar
./lib/oro-2.0.8.jar
./lib/junit-4.11.jar
./lib/spring-boot-starter-velocity-1.2.5.RELEASE.jar
./lib/jackson-core-2.4.6.jar
./lib/validation-api-1.1.0.Final.jar
./lib/jboss-logging-annotations-1.2.0.Beta1.jar
./lib/spring-data-jpa-1.7.3.RELEASE.jar
./lib/snakeyaml-1.14.jar
./lib/tomcat-embed-logging-juli-7.0.59.jar
./lib/commons-lang-2.6.jar
./lib/ehcache-2.8.5.jar
./lib/hamcrest-library-1.3.jar
./lib/commons-io-2.4.jar
./lib/spring-web-4.1.7.RELEASE.jar
./lib/spring-boot-1.2.5.RELEASE.jar
./lib/spring-context-support-4.1.7.RELEASE.jar
./lib/spring-boot-starter-aop-1.2.5.RELEASE.jar
./lib/objenesis-2.1.jar
./lib/spring-core-4.1.7.RELEASE.jar
./lib/jackson-annotations-2.4.6.jar
./lib/jackson-databind-2.4.6.jar
./lib/hibernate-validator-5.1.3.Final.jar
./lib/spring-boot-starter-jdbc-1.2.5.RELEASE.jar
./lib/hamcrest-core-1.3.jar
./lib/tomcat-embed-core-7.0.59.jar
./lib/spring-aspects-4.1.7.RELEASE.jar
./lib/spring-test-4.1.7.RELEASE.jar
./lib/spring-beans-4.1.7.RELEASE.jar
./lib/commons-collections-3.2.1.jar
./lib/log4j-1.2.17.jar
./lib/aspectjweaver-1.8.6.jar
./lib/javassist-3.18.1-GA.jar
./lib/spring-boot-starter-test-1.2.5.RELEASE.jar
./lib/hibernate-core-4.3.10.Final.jar
./lib/xml-apis-1.0.b2.jar
./lib/spring-boot-starter-1.2.5.RELEASE.jar
./lib/slf4j-log4j12-1.7.12.jar
./lib/tomcat-jdbc-7.0.59.jar
./lib/spring-boot-starter-actuator-1.2.5.RELEASE.jar
./lib/ojdbc7-12.1.0.1.0.jar
./static
./static/WEB-INF
./static/WEB-INF/tools.xml
./mainweb.jar
启动
java -jar mainweb.jar