3 回答
TA贡献1798条经验 获得超7个赞
使用 jar 文件很容易,命令:maven install
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>com.dh.Application</mainClass>
<jvmArguments>-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005
</jvmArguments>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
TA贡献1848条经验 获得超10个赞
根据您的问题描述,我希望不需要百里香。
您可以通过 2 种方式进行。
如果确实不需要,则从 pom.xml 中删除 thymeleaf 模板文件夹和 thymeleaf 依赖项并继续。
你想继续使用 thymeleaf,请添加下面的类并继续部署并尝试。
@Configuration
public class ThymeleafConfiguration {
private static final String HTML_5 = "HTML5";
@Bean
public SpringTemplateEngine templateEngine() {
final SpringTemplateEngine templateEngine = new SpringTemplateEngine();
templateEngine.addTemplateResolver(templateResolver());
return templateEngine;
}
@Bean
public ThymeleafViewResolver viewResolver(){
final ThymeleafViewResolver viewResolver = new ThymeleafViewResolver();
viewResolver.setTemplateEngine(templateEngine());
viewResolver.setViewNames(new String[]{"*.html,*.xhtml,*.txt"});
return viewResolver;
}
@Bean
public SpringResourceTemplateResolver templateResolver() {
// SpringResourceTemplateResolver automatically integrates with Spring's
// own resource resolution infrastructure, which is highly recommended.
final SpringResourceTemplateResolver templateResolver = new SpringResourceTemplateResolver();
// templateResolver.setApplicationContext(this.applicationContext);
templateResolver.setPrefix("classpath:templates/");
templateResolver.setSuffix(".html");
// HTML is the default value, added here for the sake of clarity.
templateResolver.setTemplateMode(HTML_5);
templateResolver.setCharacterEncoding(CharEncoding.UTF_8);
// Template cache is true by default. Set to false if you want
// templates to be automatically updated when modified.
templateResolver.setCacheable(true);
return templateResolver;
}
}
TA贡献1765条经验 获得超5个赞
因为默认spring-boot-starter-web包含 Tomcat 。 如果你想在其他 web 容器中运行你的应用程序,你应该为 Spring MVC 排除 Tomcat,如下所示: spring-boot-starter-tomcat
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<!-- Exclude the Tomcat dependency -->
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
添加回答
举报