3 回答

TA貢獻(xiàn)1798條經(jīng)驗(yàn) 獲得超7個(gè)贊
使用 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貢獻(xiàn)1848條經(jīng)驗(yàn) 獲得超10個(gè)贊
根據(jù)您的問(wèn)題描述,我希望不需要百里香。
您可以通過(guò) 2 種方式進(jìn)行。
如果確實(shí)不需要,則從 pom.xml 中刪除 thymeleaf 模板文件夾和 thymeleaf 依賴(lài)項(xiàng)并繼續(xù)。
你想繼續(xù)使用 thymeleaf,請(qǐng)?zhí)砑酉旅娴念?lèi)并繼續(xù)部署并嘗試。
@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貢獻(xiàn)1765條經(jīng)驗(yàn) 獲得超5個(gè)贊
因?yàn)槟J(rèn)spring-boot-starter-web包含 Tomcat 。 如果你想在其他 web 容器中運(yùn)行你的應(yīng)用程序,你應(yīng)該為 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>
添加回答
舉報(bào)