1. vue project directory, build generating dist catalogs npm run, copy and static index.html resource directory to the directory of the project SpringBoot
This time found that start Springboot project can not be opened index page
For example: http: // localhost: 8087 / index.html
After initially Baidu is a relative and absolute paths are not the right questions, modify the index.js under the confid Vue, the '/' modified to point with './' path
Na later found or not, so think of ways to solve
Plus a default path, access / or access / index jump allowed to index.html
I think of the template engine to use, it added thymeleaf, writing a controller method, as long as access to the root directory will automatically jump to the index.html [This is a solution 1, after the Code]
Do all projects have to do so?
After careful study found that online tutorials are the vue generated files copied to the new directory under static resource directory under SpringBoot project, so Yihuhuhuapiao, that need to create a static route, under static directory index.html placement and static directory
OMG, changed the directory, you can successfully interviewed ~~
Do all projects have to do so? Why have to be a static directory, I can not specify a catalog?
Can, of course, to add the following code in the configuration file application.properies
spring.resources.static-locations=classpath:/testFo
Now say something about why the default does not have to be static?
Because Springboot default static resource directory
classpath:/static
classpath:/public
classpath:/resources
classpath:/META-INF/resources
难道没有别的方式了吗?
有,既然是静态资源,能不能直接放在nginx上呢。可以的【之后再讲】
2. 部署好了,能访问页面了,本机啥都是好的,其他机器通过ip和端口访问,妈呀,只有页面,数据呢
Solution:
这个我不得不在我所有的接口前面加个api路径~也就是在配置文件中添加了一个默认访问的前缀~暂时还没有找到更好的办法