gpt4 book ai didi

spring-boot - thymeleaf-spring4:jar无法找到工件-Gradle Intellij

转载 作者:行者123 更新时间:2023-12-03 05:09:12 25 4
gpt4 key购买 nike

我正在尝试使用gradle,groovy和spring-boot框架通过以下代码构建一个简单的应用程序:

@Grab("thymeleaf-spring4")

@Controller
class ViewBasedApp {
def chapters = ["Quick Start With Groovy",
"Quick Start With Java",
"Debugging and Managing Your App",
"Data Access with Spring Boot",
"Securing Your App"]
@RequestMapping("/")
def home(@RequestParam(value="name", defaultValue="World") String n) {
new ModelAndView("home")
.addObject("name", n)
.addObject("chapters", chapters)
}
}

这是我的build.gradle文件:
group 'LoginApp'
version '1.0-SNAPSHOT'

apply plugin: 'groovy'

repositories {
mavenCentral()
}

dependencies {
compile 'org.codehaus.groovy:groovy-all:2.3.11'
testCompile group: 'junit', name: 'junit', version: '4.12'

compile("org.springframework.boot:spring-boot-starter-web")
//compile("org.thymeleaf:thymeleaf-spring4") //first try
// compile("nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect") //first try
compile 'org.springframework:spring-webmvc:3.0.0.RELEASE'

// https://mvnrepository.com/artifact/org.thymeleaf/thymeleaf-spring4 //secound try
compile group: 'org.thymeleaf', name: 'thymeleaf-spring4', version: '3.0.0.RELEASE'
// compile group: 'org.thymeleaf', name: 'thymeleaf-spring4', version: '4.1.6.RELEASE' //third try
}

html文件:
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Learning Spring Boot - Chapter 1</title>
</head>
<body>
<p th:text="'Hello, ' + ${name}"></p>
<ol>
<li th:each="chapter : ${chapters}" th:text="${chapter}"></li>
</ol>
</body>
</html>

要启动我的应用程序,我使用Spring Boot CLI。当我在命令提示符下使用“spring run”时,总是遇到相同的错误:
在本地(文件:/ C:/ Users / kubas / repository)中找不到 Artifact :thymeleaf-spring4:jar:。

我试图将“thymeleaf-spring4.jar”(从maven页面下载)添加到文件夹“repository”,什么也没有,总是相同的错误。

有人可以建议吗?

最佳答案

我通过从本地存储库添加依赖项解决了问题:

buildscript {
repositories {
mavenLocal()
}
dependencies {
classpath("org.thymeleaf:thymeleaf-spring5:3.0.9.RELEASE")
}
}
repositories {
mavenCentral()
}

dependencies {
compile 'org.codehaus.groovy:groovy-all:2.3.11'
testCompile group: 'junit', name: 'junit', version: '4.12'
compile("org.springframework.boot:spring-boot-starter-web")
compile("nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect") //first try
compile 'org.springframework:spring-webmvc:4.0.6.RELEASE'
compile 'org.springframework:spring-web:4.0.6.RELEASE' //@EnableWebMvc @ComponentScan
}

现在从C:\ Users \ kubas \ org \ thymeleaf \ thymeleaf-spring5提取百里香叶

我必须将app.groovy中的注释更改为 @Grab("thymeleaf-spring5")
但现在我无法配置模板文件的路径。我到此文件的路径是: F:\gradle_login_aPP\src\main\resources\templates ...

这是错误:

Cannot find template location: classpath:/templates/



我尝试在 \src\main\resources\中添加application.properties文件,但是它不起作用。我知道可以添加默认前缀,但是我找不到有关文件的信息,我需要在其中添加它。有什么建议,如何使用gradle项目运行此模板?

关于spring-boot - thymeleaf-spring4:jar无法找到工件-Gradle Intellij,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50887879/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com