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>
添加回答
舉報