44237


デスクトップに以下の内容のapp.groovyというファイルを置いています。

[code]

    @Grab("thymeleaf-spring4")
    @Controller
    class App {
    
      @RequestMapping("/")
      @ResponseBody
      def home(ModelAndView mav) {
        mav.setViewName("home")
        mav
      }
    }
    
[/code]

同じくデスクトップ上で「templates」というフォルダを用意し、その中にhome.htmlという以下の内容のhtmlファイルを用意しています。

[code]

    <!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>
    
[/code]

コマンドプロンプトで `run app.groovy`
を打ったとき、想定ではtemplatesフォルダ配下のhome.htmlを読み込み、localhost:8080で表示できるはずでした。が、以下のエラーが出てしまっています。どうすればよいでしょうか。。  
なお、app.groovyに単純にhello worldを書くだけであれば `run app.groovy`
でlocalhost:8080で表示できます。また、使用しているパソコンにはeclipseやSTSが入っています。

コマンドプロンプトのエラー内容

[code]

    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
    
[/code]


CC BY-SA 4.0
2018-05-24T15:34:22.813
44231
2018-05-25T02:11:23.893
2018-05-24T18:05:09.437
19110
23122
question
java eclipse spring groovy
Spring Boot CLIでgroovyというファイルを実行しようとするが、templatesフォルダを読み込みに行かずうまくいかない


app.groovyの次の行を

[code]

    @Grab("thymeleaf-spring4")
    
[/code]

以下のように変更してみて下さい。

[code]

    @Grab("thymeleaf-spring5")
    
[/code]

[このページ](https://docs.spring.io/spring-
boot/docs/current/reference/htmlsingle/#appendix-dependency-
versions)を見ると、`thymeleaf-spring4`はありません。

[ドキュメント](https://docs.spring.io/spring-
boot/docs/current/reference/htmlsingle/#cli-default-grab-deduced-
coordinates)には、以下のように注意書きが書いてあります。

> The default metadata is tied to the version of the CLI that you use. it
> changes only when you move to a new version of the CLI, putting you in
> control of when the versions of your dependencies may change. A table
> showing the dependencies and their versions that are included in the default
> metadata can be found in the appendix.


CC BY-SA 4.0
2018-05-25T02:11:23.893
44237
2018-05-25T02:11:23.893
21092
44231
answer