打包vue 放入 fast的项目中格式
版本:renren-fast 1.2
开发环境:火狐
我打包之后,放到了 路径 ../resources/templates/dist/ 下面,新建了个 controller 进行访问。
pom还设置了thymeleaf:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
如图:img[//cdn.renren.io/572ab201808130942505917.jpg] ,img[//cdn.renren.io/591f0201808130943005012.jpg]
问题:我访问 http://localhost:8081/dist/index 时候,提示我
img[//cdn.renren.io/7d9be20180813095208716.jpg]
这个应该怎么放置位置?或者设置什么可以静态访问js
回帖
2018-08-13
可以放到static或public目录下,看下springboot的目录结构,就明白了
2018-08-13
@Mark 我放到 static 或者 public 下试了。。。他让我传入一个 token才可以。。。这个没改掉,所以才想着放temples里。。。
现在就是报错这个
java.lang.IllegalStateException: createToken method implementation returned null. A valid non-null AuthenticationToken must be created in order to execute a login attempt.
2018-08-13
@逍遥神 还需要改下ShiroConfig.java 放行这几个目录
2018-08-13
我 index.html 的路径是 /src/main/resources/static/dist/index.html,
然后 ShiroConfig.java 添加了 filterMap.put("/dist/**", "anon");
application.yml 中映射没有动,依旧是 mvc.static-path-pattern: /static/**
访问:http://localhost:8081/dist/index.html 会给我报错 org.springframework.web.servlet.NoHandlerFoundException: No handler found for GET /dist/index.html。
这个是什么原因呢?
2018-08-13
这个 fast 和 security 感觉不太一样呢.....我用security 设置个 html ,从shiro里设置就能访问到了。在 fast里就不行.....
2018-08-13
@Mark 解决了,直接访问,放 public 还是 static,都找不到路径。
我重新写了个
public class StaticConfig implements WebMvcConfigurer {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("index.html").addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/dist/**").addResourceLocations("classpath:/static/dist/");
}
}
再去访问就可以了。