1)找到spring-boot-autoconfigure-xxx.jar
2)进入org.springframework. boot. autoconfigure->web-ServerProperties
3)Application.yml文件添加:
#tomcat端口修改 server: port: 80
访问:http://localhost/hello
结果:hello,spring boot!
静态资源放置的位置;放置静态资源并访问这些资源
public static class Resources { private static final String[] CLASSPATH_RESOURCE_LOCATIONS = new String[]{"classpath:/META-INF/resources/", "classpath:/resources/", "classpath:/static/", "classpath:/public/"}; private String[] staticLocations; }
resources下新建一个static包,将图片放在static包里(html 和 css都可以访问)
访问:http://localhost/3.jpeg
访问结果: