mavenspring-bootspring-mvcapache-tiles

What is different between compile and provided


When I set <scope> to provided, my application didn't work. When It was compile, however, It works. Can you explain what different between both them.

This is tileConfig class for setting path.

@Configuration
public class TilesConfig {

    @Bean
    public ViewResolver viewResolver() {
        UrlBasedViewResolver viewResolver = new UrlBasedViewResolver();
        viewResolver.setViewClass(TilesView.class);
        return viewResolver;
    }

    @Bean
    public TilesConfigurer tilesConfigurer() {
        TilesConfigurer tilesConfigurer = new TilesConfigurer();
        tilesConfigurer.setDefinitions("/WEB-INF/tiles.xml");

        return tilesConfigurer;
}

and I added dependencies for Apache Tiles 3 and JSP. Because embedded server (tomcat) in Spring Boot do not support JPS.

Following pom.xml is working but when I add <scope> as provided in tomcat-embed-jasper. It does not work:

    <!-- Apache Tiles 3 -->
    <dependency>
        <groupId>org.apache.tiles</groupId>
        <artifactId>tiles-jsp</artifactId>
        <version>3.0.8</version>
    </dependency>

    <!-- JSP -->
    <dependency>
        <groupId>org.apache.tomcat.embed</groupId>
        <artifactId>tomcat-embed-jasper</artifactId>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
    </dependency>

Solution

  • If you specify the scope as provided, you are saying that you expect JDK or the container to provide the dependency at runtime. This dependency is not present there so it cannot find it.