@
springmarker 修改 pom.xml:
<packaging>war</packaging>
然后再部署试试,如果还不行可以。利用 servler3.0 新特性动态加载,resources 目录下新建个 web.xml 然后配置:
```
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="
http://java.sun.com/xml/ns/javaee" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<listener>
<listener-class>com.xxx.cloud.context.ContextLoaderListener</listener-class>
</listener>
</web-app>
```
ContextLoaderListener.java
```
package com.anbai.cloud.context;
import com.anbai.cloud.config.CloudApplication;
import org.springframework.boot.SpringApplication;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import java.util.logging.Logger;
/**
* Cloud 启动监听器,利用 Servlet 3.x 动态创建 Spring 的 Servlet
*/
public class ContextLoaderListener implements ServletContextListener {
private static final Logger LOG = Logger.getLogger("info");
@
Override public void contextInitialized(ServletContextEvent sce) {
System.setProperty("file.encoding", "UTF-8");
SpringApplication.run(CloudApplication.class, null);
}
@
Override public void contextDestroyed(ServletContextEvent sce) {
LOG.info("Context " + sce.getServletContext() + " Destroyed...");
}
}
```