Following symbolic link in Grails 3

放肆的年华 提交于 2019-12-06 05:32:28

Finally, I've figured out the solution for following symbolic link in Grails 3 with the help of examples provided by graemerocher.

You just need to add the following to your ./grails-app/init/<package>/Application.groovy:

@Bean
EmbeddedServletContainerFactory containerFactory() {
    TomcatEmbeddedServletContainerFactory containerFactory = new TomcatEmbeddedServletContainerFactory()

    containerFactory.addContextCustomizers(new TomcatContextCustomizer() {
        @Override
        void customize(Context context) {
            StandardRoot root = new StandardRoot(context)
            root.setAllowLinking(true)
            context.setResources(root)
        }
    });

    return containerFactory
}

Packages to import:

import org.apache.catalina.Context
import org.apache.catalina.webresources.StandardRoot
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory
import org.springframework.boot.context.embedded.tomcat.TomcatContextCustomizer
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory
import org.springframework.context.annotation.Bean
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!