如何为Tiles配置器定义路径?

时间:2018-01-25 09:00:24

标签: spring-mvc web-deployment apache-tiles

My Spring应用程序无法启动,因为到目前为止工作正常的tiles.xml文件的路径无法访问。我可以在本地部署它,但是当我创建.war以将其上传到服务器时,它会给我错误。

在我部署应用程序时,是否有人可以告诉我应该定义多少路径不会导致此错误崩溃? (为什么)。

这是我的限定名称是...路径:/VotaIdeas/src/main/webapp/WEB-INF/tiles.xml

  

2018-01-25 09:43:26.015 ERROR 2587 --- [-nio-80-exec-77] o.s.boot.SpringApplication
    :应用程序启动失败   org.springframework.beans.factory.BeanCreationException:创建名称为' tilesCon的bean时出错   figurer'在com.caveofprogramming.App中定义:init方法的调用失败;嵌套异常   n是java.lang.IllegalArgumentException:没有ServletContext资源的URL [ /WEB-INF/tiles.xml ]           在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initiali   zeBean(AbstractAutowireCapableBeanFactory.java:1578)〜[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELE   ASE]           在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreate   Bean(AbstractAutowireCapableBeanFactory.java:545)〜[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE   ]

...这里是App.java中的tiles配置器:

@Bean
public TilesConfigurer tilesConfigurer() {
    TilesConfigurer tilesConfigurer = new TilesConfigurer();

    String[] defs = {"/WEB-INF/tiles.xml"};

    tilesConfigurer.setDefinitions(defs);

    return tilesConfigurer;
}

Files structure

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.3.5.RELEASE</version>
</parent>


<properties>
    <java.version>1.8</java.version>
    <tiles.version>3.0.5</tiles.version>
</properties>

<groupId>com.caveofprogramming</groupId>
<artifactId>spring-boot-tutorial</artifactId>
<version>1.0</version>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.apache.tomcat.embed</groupId>
        <artifactId>tomcat-embed-jasper</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.tiles</groupId>
        <artifactId>tiles-core</artifactId>
        <version>${tiles.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.tiles</groupId>
        <artifactId>tiles-jsp</artifactId>
        <version>${tiles.version}</version>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
    </dependency>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-taglibs</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-mail</artifactId>
    </dependency>
    <dependency>
        <groupId>com.googlecode.owasp-java-html-sanitizer</groupId>
        <artifactId>owasp-java-html-sanitizer</artifactId>
        <version>20160628.1</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-test</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>
    <dependency>
        <groupId>org.postgresql</groupId>
        <artifactId>postgresql</artifactId>
    </dependency>
</dependencies>

<packaging>war</packaging>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <executable>true</executable>
            </configuration>
        </plugin>
    </plugins>
</build>

.war file

left works, right does not work

Web Deployment Assembly

0 个答案:

没有答案