デスクトップに以下の内容のapp.groovyというファイルを置いています。
@Grab("thymeleaf-spring4")
@Controller
class App {
@RequestMapping("/")
@ResponseBody
def home(ModelAndView mav) {
mav.setViewName("home")
mav
}
}
同じくデスクトップ上で「templates」というフォルダを用意し、その中にhome.htmlという以下の内容のhtmlファイルを用意しています。
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type"
content"text/html; charset=utf-8" />
<title>Index Page</title>
<style>
h1 { font-size:18pt; font-weight:bold; color:gray; }
body { font-size:13pt; color:gray; margin:5px 25px; }
</style>
</head>
<body>
<h1>Hello!</h1>
<p>this is sample web page.</p>
</body>
</html>
コマンドプロンプトで run app.groovy
を打ったとき、想定ではtemplatesフォルダ配下のhome.htmlを読み込み、localhost:8080で表示できるはずでした。が、以下のエラーが出てしまっています。どうすればよいでしょうか。。
なお、app.groovyに単純にhello worldを書くだけであれば run app.groovy
でlocalhost:8080で表示できます。また、使用しているパソコンにはeclipseやSTSが入っています。
コマンドプロンプトのエラー内容
C:\Users\yoshi\Desktop>spring run app.groovy
Resolving dependencies......
startup failed:
General error during conversion: org.eclipse.aether.resolution.DependencyResolutionException: Could not find artifact :thymeleaf-spring4:jar: in local (file:/C:/Users/yoshi/Desktop/repository)
org.springframework.boot.cli.compiler.grape.DependencyResolutionFailedException: org.eclipse.aether.resolution.DependencyResolutionException: Could not find artifact :thymeleaf-spring4:jar: in local (file:/C:/Users/yoshi/Desktop/repository)
at org.springframework.boot.cli.compiler.grape.AetherGrapeEngine.resolve(AetherGrapeEngine.java:311)
at org.springframework.boot.cli.compiler.grape.AetherGrapeEngine.grab(AetherGrapeEngine.java:119)
at groovy.grape.Grape.grab(Grape.java:167)
at groovy.grape.GrabAnnotationTransformation.visit(GrabAnnotationTransformation.java:376)
at org.codehaus.groovy.transform.ASTTransformationVisitor$3.call(ASTTransformationVisitor.java:346)
at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:966)
at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:626)
at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:602)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:579)
at org.springframework.boot.cli.compiler.GroovyCompiler.compile(GroovyCompiler.java:207)
at org.springframework.boot.cli.command.run.SpringApplicationRunner.compile(SpringApplicationRunner.java:129)
at org.springframework.boot.cli.command.run.SpringApplicationRunner.compileAndRun(SpringApplicationRunner.java:101)
at org.springframework.boot.cli.command.run.RunCommand$RunOptionHandler.run(RunCommand.java:111)
at org.springframework.boot.cli.command.options.OptionHandler.run(OptionHandler.java:84)
at org.springframework.boot.cli.command.OptionParsingCommand.run(OptionParsingCommand.java:54)
at org.springframework.boot.cli.command.CommandRunner.run(CommandRunner.java:219)
at org.springframework.boot.cli.command.CommandRunner.runAndHandleErrors(CommandRunner.java:171)
at org.springframework.boot.cli.SpringCli.main(SpringCli.java:63)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
Caused by: org.eclipse.aether.resolution.DependencyResolutionException: Could not find artifact :thymeleaf-spring4:jar: in local (file:/C:/Users/yoshi/Desktop/repository)
at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveDependencies(DefaultRepositorySystem.java:384)
at org.springframework.boot.cli.compiler.grape.AetherGrapeEngine.resolve(AetherGrapeEngine.java:306)
... 25 more
Caused by: org.eclipse.aether.resolution.ArtifactResolutionException: Could not find artifact :thymeleaf-spring4:jar: in local (file:/C:/Users/yoshi/Desktop/repository)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:444)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:246)
at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveDependencies(DefaultRepositorySystem.java:367)
... 26 more
Caused by: org.eclipse.aether.transfer.ArtifactNotFoundException: Could not find artifact :thymeleaf-spring4:jar: in local (file:/C:/Users/yoshi/Desktop/repository)
at org.eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed(ArtifactTransportListener.java:39)
at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:355)
at org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:67)
at org.eclipse.aether.connector.basic.BasicRepositoryConnector$DirectExecutor.execute(BasicRepositoryConnector.java:581)
at org.eclipse.aether.connector.basic.BasicRepositoryConnector.get(BasicRepositoryConnector.java:249)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:520)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:421)
... 28 more
1 error
{}
ボタンを押すと自動的に装飾してくれるので、次回からご利用ください。