Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Java Spring with Hibernate Integrating Hibernate with Spring Revisiting Giflib

Jiamin Chen
Jiamin Chen
5,474 Points

Some library seems to be missing

I downloaded the project file, via GitHub and link on Treehouse, and tried either opening the project or importing via existing source, but none of them works. They all show the springframework.boot and some other libraries as unrecognized, despite the dependencies being the same as the project file. Downloading the springframework.boot doesn't help either.

The Gradle project window says "unable to resolve org.springframework.boot:spring-boot-starter-thymeleaf"

Do you have the following lines in the build.gradle file:

// Include the Spring Boot plugin
buildscript {
    repositories{
        mavenCentral()
    }
    dependencies {
        classpath 'org.springframework.boot:spring-boot-gradle-plugin:1.3.3.RELEASE'
    }
}

// Apply the Spring Boot plugin
apply plugin: 'spring-boot'
Jiamin Chen
Jiamin Chen
5,474 Points

The only way I can get it to compile is to use this:

buildscript {
    ext {
        springBootVersion = '2.0.1.RELEASE'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

group = 'com.teamtreehouse'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8

repositories {
    mavenCentral()
}


dependencies {
    compile 'org.springframework.boot:spring-boot-starter-thymeleaf'
// https://mvnrepository.com/artifact/org.springframework/spring-web
    compile group: 'org.springframework', name: 'spring-web', version: '5.0.5.RELEASE'
// https://mvnrepository.com/artifact/org.springframework/spring-webmvc
    compile group: 'org.springframework', name: 'spring-webmvc', version: '5.0.5.RELEASE'
    compile 'org.hashids:hashids:1.0.1'
    compile 'org.springframework:spring-orm:4.2.5.RELEASE'
    compile 'org.hibernate:hibernate-core:5.2.1.Final'
    compile 'org.apache.tomcat:tomcat-dbcp:8.0.32'
    compile 'com.h2database:h2:1.4.191'
    compile 'org.thymeleaf:thymeleaf-spring4:3.0.9.RELEASE'
}

It launches Spring and I get the colored text outputs. But after a second or so I get an error:

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2018-04-08 02:47:35.828 ERROR 19392 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'viewResolver' defined in class path resource [com/teamtreehouse/giflib/config/TemplateConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.thymeleaf.spring4.view.ThymeleafViewResolver]: Factory method 'viewResolver' threw exception; nested exception is java.lang.IllegalStateException: @Bean method TemplateConfig.templateEngine called as bean reference for type [org.thymeleaf.spring4.SpringTemplateEngine] but overridden by non-compatible bean instance of type [org.thymeleaf.spring5.SpringTemplateEngine]. Overriding bean of same name declared in: class path resource [org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration$ThymeleafDefaultConfiguration.class]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:587) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1250) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1099) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:541) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:501) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$$Lambda$83/15970265.getObject(Unknown Source) ~[na:na]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:760) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:869) ~[spring-context-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) ~[spring-context-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) [spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:395) [spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) [spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1255) [spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1243) [spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]
    at com.teamtreehouse.giflib.Application.main(Application.java:11) [classes/:na]
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.thymeleaf.spring4.view.ThymeleafViewResolver]: Factory method 'viewResolver' threw exception; nested exception is java.lang.IllegalStateException: @Bean method TemplateConfig.templateEngine called as bean reference for type [org.thymeleaf.spring4.SpringTemplateEngine] but overridden by non-compatible bean instance of type [org.thymeleaf.spring5.SpringTemplateEngine]. Overriding bean of same name declared in: class path resource [org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration$ThymeleafDefaultConfiguration.class]
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:579) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    ... 18 common frames omitted
Caused by: java.lang.IllegalStateException: @Bean method TemplateConfig.templateEngine called as bean reference for type [org.thymeleaf.spring4.SpringTemplateEngine] but overridden by non-compatible bean instance of type [org.thymeleaf.spring5.SpringTemplateEngine]. Overriding bean of same name declared in: class path resource [org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration$ThymeleafDefaultConfiguration.class]
    at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.resolveBeanReference(ConfigurationClassEnhancer.java:415) ~[spring-context-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:364) ~[spring-context-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at com.teamtreehouse.giflib.config.TemplateConfig$$EnhancerBySpringCGLIB$$ceb88642.templateEngine(<generated>) ~[classes/:na]
    at com.teamtreehouse.giflib.config.TemplateConfig.viewResolver(TemplateConfig.java:30) ~[classes/:na]
    at com.teamtreehouse.giflib.config.TemplateConfig$$EnhancerBySpringCGLIB$$ceb88642.CGLIB$viewResolver$2(<generated>) ~[classes/:na]
    at com.teamtreehouse.giflib.config.TemplateConfig$$EnhancerBySpringCGLIB$$ceb88642$$FastClassBySpringCGLIB$$d008e23c.invoke(<generated>) ~[classes/:na]
    at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) ~[spring-core-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:361) ~[spring-context-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at com.teamtreehouse.giflib.config.TemplateConfig$$EnhancerBySpringCGLIB$$ceb88642.viewResolver(<generated>) ~[classes/:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_40]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_40]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_40]
    at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_40]
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    ... 19 common frames omitted


Process finished with exit code 1

Not sure if that is normal at this point. This is just with the first project file downloaded without any code edits.

5 Answers

Every course I started I got stuck on broken code and have to google for hours, teachers code is most of the time broken. Outdated course not worth time and money iMHO the only courses I've found so far that are working are those on Udemy!

It looks like the Spring Boot plugin isn't running. This plugin allows you to add a dependency without version number and let gradle get the latest version.

You added some more dependencies to spring webmvc and spring web, and while it may look like it resolves some issues on the surface, they're not the right dependencies for this project. The error you get is because of the missing thymeleaf components.

Try referencing the version number explicitly instead. Your build.gradle file should be like this (the important part is the version number added to the first dependency):

group 'com.teamtreehouse'
version '1.0-SNAPSHOT'

// Include the Spring Boot plugin
buildscript {
    repositories{
        mavenCentral()
    }
    dependencies {
        classpath 'org.springframework.boot:spring-boot-gradle-plugin:1.3.3.RELEASE'
    }
}

// Apply the Spring Boot plugin
apply plugin: 'spring-boot'

// Apply the Java plugin (expects src/main/java to be source folder)
apply plugin: 'java'

// Specify the location where our dependencies will be found
repositories {
    mavenCentral()
}

// Specify dependencies
dependencies {
    compile 'org.springframework.boot:spring-boot-starter-thymeleaf:2.0.1.RELEASE'
    compile 'org.hashids:hashids:1.0.1'
    compile 'org.springframework:spring-orm:4.2.5.RELEASE'
    compile 'org.hibernate:hibernate-core:5.2.1.Final'
    compile 'org.apache.tomcat:tomcat-dbcp:8.0.32'
    compile 'com.h2database:h2:1.4.191'
}
Jiamin Chen
Jiamin Chen
5,474 Points

Still, the plugin fails to load when I change my file to include the version. I tried using your code exactly and it still wouldn't load the plugin.

org.gradle.api.internal.plugins.PluginApplicationException: Failed to apply plugin [class 'io.spring.gradle.dependencymanagement.DependencyManagementPlugin']
    at org.gradle.api.internal.plugins.DefaultPluginManager.doApply(DefaultPluginManager.java:150)
    at org.gradle.api.internal.plugins.DefaultPluginManager.addImperativePlugin(DefaultPluginManager.java:80)
    at org.gradle.api.internal.plugins.DefaultPluginManager.addImperativePlugin(DefaultPluginManager.java:86)
    at org.gradle.api.internal.plugins.DefaultPluginContainer.apply(DefaultPluginContainer.java:60)
    at org.springframework.boot.gradle.dependencymanagement.DependencyManagementPluginFeatures.apply(DependencyManagementPluginFeatures.java:44)
    at org.springframework.boot.gradle.SpringBootPlugin.apply(SpringBootPlugin.java:47)
    at org.springframework.boot.gradle.SpringBootPlugin.apply(SpringBootPlugin.java:38)
    at org.gradle.api.internal.plugins.ImperativeOnlyPluginTarget.applyImperative(ImperativeOnlyPluginTarget.java:42)
    at org.gradle.api.internal.plugins.RuleBasedPluginTarget.applyImperative(RuleBasedPluginTarget.java:50)
    at org.gradle.api.internal.plugins.DefaultPluginManager.addPlugin(DefaultPluginManager.java:165)
    at org.gradle.api.internal.plugins.DefaultPluginManager.access$200(DefaultPluginManager.java:47)
    at org.gradle.api.internal.plugins.DefaultPluginManager$AddPluginBuildOperation.run(DefaultPluginManager.java:252)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
    at org.gradle.api.internal.plugins.DefaultPluginManager.doApply(DefaultPluginManager.java:144)
    at org.gradle.api.internal.plugins.DefaultPluginManager.apply(DefaultPluginManager.java:125)
    at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.applyType(DefaultObjectConfigurationAction.java:120)
    at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.access$200(DefaultObjectConfigurationAction.java:38)
    at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction$3.run(DefaultObjectConfigurationAction.java:86)
    at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.execute(DefaultObjectConfigurationAction.java:143)
    at org.gradle.api.internal.project.AbstractPluginAware.apply(AbstractPluginAware.java:46)
    at org.gradle.api.internal.project.ProjectScript.apply(ProjectScript.java:34)
    at org.gradle.api.Script$apply$0.callCurrent(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166)
    at build_87e4icl82va9ervfd3hmfa1ys.run(E:\Users\Jiamin\OneDrive\Documents\Programming\giflib-gradle-builder\build.gradle:13)
    at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:90)
    at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl$2.run(DefaultScriptPluginFactory.java:199)
    at org.gradle.configuration.ProjectScriptTarget.addConfiguration(ProjectScriptTarget.java:77)
    at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:204)
    at org.gradle.configuration.BuildOperationScriptPlugin$1.run(BuildOperationScriptPlugin.java:61)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
    at org.gradle.configuration.BuildOperationScriptPlugin.apply(BuildOperationScriptPlugin.java:58)
    at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:41)
    at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:26)
    at org.gradle.configuration.project.ConfigureActionsProjectEvaluator.evaluate(ConfigureActionsProjectEvaluator.java:34)
    at org.gradle.configuration.project.LifecycleProjectEvaluator.doConfigure(LifecycleProjectEvaluator.java:64)
    at org.gradle.configuration.project.LifecycleProjectEvaluator.access$100(LifecycleProjectEvaluator.java:34)
    at org.gradle.configuration.project.LifecycleProjectEvaluator$ConfigureProject.run(LifecycleProjectEvaluator.java:110)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
    at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:50)
    at org.gradle.api.internal.project.DefaultProject.evaluate(DefaultProject.java:666)
    at org.gradle.api.internal.project.DefaultProject.evaluate(DefaultProject.java:135)
    at org.gradle.execution.TaskPathProjectEvaluator.configure(TaskPathProjectEvaluator.java:35)
    at org.gradle.execution.TaskPathProjectEvaluator.configureHierarchy(TaskPathProjectEvaluator.java:60)
    at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:38)
    at org.gradle.initialization.DefaultGradleLauncher$ConfigureBuild.run(DefaultGradleLauncher.java:249)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
    at org.gradle.initialization.DefaultGradleLauncher.configureBuild(DefaultGradleLauncher.java:167)
    at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:126)
    at org.gradle.initialization.DefaultGradleLauncher.executeTasks(DefaultGradleLauncher.java:109)
    at org.gradle.internal.invocation.GradleBuildController$1.call(GradleBuildController.java:78)
    at org.gradle.internal.invocation.GradleBuildController$1.call(GradleBuildController.java:75)
    at org.gradle.internal.work.DefaultWorkerLeaseService.withLocks(DefaultWorkerLeaseService.java:152)
    at org.gradle.internal.invocation.GradleBuildController.doBuild(GradleBuildController.java:100)
    at org.gradle.internal.invocation.GradleBuildController.run(GradleBuildController.java:75)
    at org.gradle.tooling.internal.provider.runner.BuildModelActionRunner.run(BuildModelActionRunner.java:53)
    at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
    at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
    at org.gradle.tooling.internal.provider.ValidatingBuildActionRunner.run(ValidatingBuildActionRunner.java:32)
    at org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner$1.run(RunAsBuildOperationBuildActionRunner.java:43)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
    at org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner.run(RunAsBuildOperationBuildActionRunner.java:40)
    at org.gradle.tooling.internal.provider.SubscribableBuildActionRunner.run(SubscribableBuildActionRunner.java:51)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:47)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:30)
    at org.gradle.launcher.exec.BuildTreeScopeBuildActionExecuter.execute(BuildTreeScopeBuildActionExecuter.java:39)
    at org.gradle.launcher.exec.BuildTreeScopeBuildActionExecuter.execute(BuildTreeScopeBuildActionExecuter.java:25)
    at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:80)
    at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:53)
    at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:57)
    at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:32)
    at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:36)
    at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:25)
    at org.gradle.tooling.internal.provider.ParallelismConfigurationBuildActionExecuter.execute(ParallelismConfigurationBuildActionExecuter.java:43)
    at org.gradle.tooling.internal.provider.ParallelismConfigurationBuildActionExecuter.execute(ParallelismConfigurationBuildActionExecuter.java:29)
    at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:69)
    at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:30)
    at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:59)
    at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:44)
    at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:45)
    at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:30)
    at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:67)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
    at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:37)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
    at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
    at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
    at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74)
    at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72)
    at org.gradle.util.Swapper.swap(Swapper.java:38)
    at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
    at org.gradle.launcher.daemon.server.exec.LogAndCheckHealth.execute(LogAndCheckHealth.java:55)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
    at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:62)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
    at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:82)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
    at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50)
    at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:295)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
    at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
    at java.lang.Thread.run(Thread.java:745)
Caused by: org.gradle.api.tasks.TaskInstantiationException: Could not create task of type 'DependencyManagementReportTask'.
    at org.gradle.api.internal.project.taskfactory.TaskFactory$1.call(TaskFactory.java:125)
    at org.gradle.api.internal.project.taskfactory.TaskFactory$1.call(TaskFactory.java:120)
    at org.gradle.util.GUtil.uncheckedCall(GUtil.java:436)
    at org.gradle.api.internal.AbstractTask.injectIntoNewInstance(AbstractTask.java:181)
    at org.gradle.api.internal.project.taskfactory.TaskFactory.create(TaskFactory.java:120)
    at org.gradle.api.internal.project.taskfactory.TaskFactory.create(TaskFactory.java:39)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory.create(AnnotationProcessingTaskFactory.java:49)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory.create(AnnotationProcessingTaskFactory.java:30)
    at org.gradle.api.internal.project.taskfactory.DependencyAutoWireTaskFactory.create(DependencyAutoWireTaskFactory.java:44)
    at org.gradle.api.internal.project.taskfactory.DependencyAutoWireTaskFactory.create(DependencyAutoWireTaskFactory.java:27)
    at org.gradle.api.internal.tasks.DefaultTaskContainer$TaskInstantiator.create(DefaultTaskContainer.java:301)
    at org.gradle.api.internal.tasks.DefaultTaskContainer$TaskInstantiator.create(DefaultTaskContainer.java:289)
    at org.gradle.api.internal.tasks.DefaultTaskContainer.create(DefaultTaskContainer.java:116)
    at org.gradle.api.internal.tasks.DefaultTaskContainer.create(DefaultTaskContainer.java:147)
    at org.gradle.api.internal.tasks.DefaultTaskContainer_Decorated.create(Unknown Source)
    at org.gradle.api.internal.tasks.DefaultTaskContainer_Decorated$create.call(Unknown Source)
    at io.spring.gradle.dependencymanagement.DependencyManagementPlugin.apply(DependencyManagementPlugin.groovy:64)
    at io.spring.gradle.dependencymanagement.DependencyManagementPlugin.apply(DependencyManagementPlugin.groovy)
    at org.gradle.api.internal.plugins.ImperativeOnlyPluginTarget.applyImperative(ImperativeOnlyPluginTarget.java:42)
    at org.gradle.api.internal.plugins.RuleBasedPluginTarget.applyImperative(RuleBasedPluginTarget.java:50)
    at org.gradle.api.internal.plugins.DefaultPluginManager.addPlugin(DefaultPluginManager.java:165)
    at org.gradle.api.internal.plugins.DefaultPluginManager.access$200(DefaultPluginManager.java:47)
    at org.gradle.api.internal.plugins.DefaultPluginManager$AddPluginBuildOperation.run(DefaultPluginManager.java:252)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
    at org.gradle.api.internal.plugins.DefaultPluginManager.doApply(DefaultPluginManager.java:144)
    ... 126 more
Caused by: org.gradle.internal.service.UnknownServiceException: No service of type StyledTextOutputFactory available in ProjectScopeServices.
    at org.gradle.internal.service.DefaultServiceRegistry.getServiceProvider(DefaultServiceRegistry.java:352)
    at org.gradle.internal.service.DefaultServiceRegistry.doGet(DefaultServiceRegistry.java:341)
    at org.gradle.internal.service.DefaultServiceRegistry.get(DefaultServiceRegistry.java:329)
    at org.gradle.api.internal.DependencyInjectingInstantiator.convertParameters(DependencyInjectingInstantiator.java:110)
    at org.gradle.api.internal.DependencyInjectingInstantiator.newInstance(DependencyInjectingInstantiator.java:79)
    at org.gradle.api.internal.project.taskfactory.TaskFactory$1.call(TaskFactory.java:123)
    ... 153 more

Thank you! Not sure what the problem is at all.

OK, try it again with just this:

group 'com.teamtreehouse'
version '1.0-SNAPSHOT'

// Apply the Java plugin (expects src/main/java to be source folder)
apply plugin: 'java'

// Specify the location where our dependencies will be found
repositories {
    mavenCentral()
}

// Specify dependencies
dependencies {
    compile 'org.springframework.boot:spring-boot-starter-thymeleaf:2.0.1.RELEASE'
    compile 'org.hashids:hashids:1.0.1'
    compile 'org.springframework:spring-orm:4.2.5.RELEASE'
    compile 'org.hibernate:hibernate-core:5.2.1.Final'
    compile 'org.apache.tomcat:tomcat-dbcp:8.0.32'
    compile 'com.h2database:h2:1.4.191'
}
Jiamin Chen
Jiamin Chen
5,474 Points

Thanks for your help. Apparently my Gradle installation is broken. Redownloaded it and it's good!

Jiamin Chen
Jiamin Chen
5,474 Points

Thanks, but now the build console give me this: Seems like it doesn't recognize the spring-boot-starter-thymeleaf library.

Information:Internal caches are corrupted or have outdated format, forcing project rebuild: backward reference index should be updated to actual version
Information:java: Errors occurred while compiling module 'main'
Information:javac 1.8.0_40 was used to compile java sources
Information:4/12/2018 11:07 PM - Compilation completed with 85 errors and 0 warnings in 3s 918ms
E:\Users\Jiamin\OneDrive\Documents\Programming\giflib-gradle-builder\src\main\java\com\teamtreehouse\giflib\Application.java
Error:(3, 32) java: package org.springframework.boot does not exist
Error:(4, 46) java: package org.springframework.boot.autoconfigure does not exist
Error:(5, 46) java: package org.springframework.context.annotation does not exist
Error:(7, 2) java: cannot find symbol
  symbol: class EnableAutoConfiguration
Error:(8, 2) java: cannot find symbol
  symbol: class ComponentScan
Error:(11, 9) java: cannot find symbol
  symbol:   variable SpringApplication
  location: class com.teamtreehouse.giflib.Application
E:\Users\Jiamin\OneDrive\Documents\Programming\giflib-gradle-builder\src\main\java\com\teamtreehouse\giflib\config\TemplateConfig.java
Error:(3, 46) java: package org.springframework.context.annotation does not exist
Error:(4, 46) java: package org.springframework.context.annotation does not exist
Error:(5, 29) java: package org.thymeleaf.spring4 does not exist
Error:(6, 46) java: package org.thymeleaf.spring4.templateresolver does not exist
Error:(7, 34) java: package org.thymeleaf.spring4.view does not exist
Error:(9, 2) java: cannot find symbol
  symbol: class Configuration
Error:(12, 12) java: cannot find symbol
  symbol:   class SpringResourceTemplateResolver
  location: class com.teamtreehouse.giflib.config.TemplateConfig
Error:(21, 12) java: cannot find symbol
  symbol:   class SpringTemplateEngine
  location: class com.teamtreehouse.giflib.config.TemplateConfig
Error:(28, 12) java: cannot find symbol
  symbol:   class ThymeleafViewResolver
  location: class com.teamtreehouse.giflib.config.TemplateConfig
Error:(11, 6) java: cannot find symbol
  symbol:   class Bean
  location: class com.teamtreehouse.giflib.config.TemplateConfig
Error:(20, 6) java: cannot find symbol
  symbol:   class Bean
  location: class com.teamtreehouse.giflib.config.TemplateConfig
Error:(27, 6) java: cannot find symbol
  symbol:   class Bean
  location: class com.teamtreehouse.giflib.config.TemplateConfig
Error:(13, 15) java: cannot find symbol
  symbol:   class SpringResourceTemplateResolver
  location: class com.teamtreehouse.giflib.config.TemplateConfig
Error:(13, 69) java: cannot find symbol
  symbol:   class SpringResourceTemplateResolver
  location: class com.teamtreehouse.giflib.config.TemplateConfig
Error:(22, 15) java: cannot find symbol
  symbol:   class SpringTemplateEngine
  location: class com.teamtreehouse.giflib.config.TemplateConfig
Error:(22, 63) java: cannot find symbol
  symbol:   class SpringTemplateEngine
  location: class com.teamtreehouse.giflib.config.TemplateConfig
Error:(29, 15) java: cannot find symbol
  symbol:   class ThymeleafViewResolver
  location: class com.teamtreehouse.giflib.config.TemplateConfig
Error:(29, 56) java: cannot find symbol
  symbol:   class ThymeleafViewResolver
  location: class com.teamtreehouse.giflib.config.TemplateConfig
E:\Users\Jiamin\OneDrive\Documents\Programming\giflib-gradle-builder\src\main\java\com\teamtreehouse\giflib\web\controller\GifController.java
Error:(4, 38) java: package org.springframework.stereotype does not exist
Error:(5, 30) java: package org.springframework.ui does not exist
Error:(6, 1) java: package org.springframework.web.bind.annotation does not exist
Error:(11, 2) java: cannot find symbol
  symbol: class Controller
Error:(16, 28) java: cannot find symbol
  symbol:   class Model
  location: class com.teamtreehouse.giflib.web.controller.GifController
Error:(26, 56) java: cannot find symbol
  symbol:   class Model
  location: class com.teamtreehouse.giflib.web.controller.GifController
Error:(44, 29) java: cannot find symbol
  symbol:   class Model
  location: class com.teamtreehouse.giflib.web.controller.GifController
Error:(64, 30) java: cannot find symbol
  symbol:   class Model
  location: class com.teamtreehouse.giflib.web.controller.GifController
Error:(72, 57) java: cannot find symbol
  symbol:   class Model
  location: class com.teamtreehouse.giflib.web.controller.GifController
Error:(107, 57) java: cannot find symbol
  symbol:   class Model
  location: class com.teamtreehouse.giflib.web.controller.GifController
Error:(15, 6) java: cannot find symbol
  symbol:   class RequestMapping
  location: class com.teamtreehouse.giflib.web.controller.GifController
Error:(26, 31) java: cannot find symbol
  symbol:   class PathVariable
  location: class com.teamtreehouse.giflib.web.controller.GifController
Error:(25, 6) java: cannot find symbol
  symbol:   class RequestMapping
  location: class com.teamtreehouse.giflib.web.controller.GifController
Error:(37, 29) java: cannot find symbol
  symbol:   class PathVariable
  location: class com.teamtreehouse.giflib.web.controller.GifController
Error:(35, 6) java: cannot find symbol
  symbol:   class RequestMapping
  location: class com.teamtreehouse.giflib.web.controller.GifController
Error:(36, 6) java: cannot find symbol
  symbol:   class ResponseBody
  location: class com.teamtreehouse.giflib.web.controller.GifController
Error:(43, 6) java: cannot find symbol
  symbol:   class RequestMapping
  location: class com.teamtreehouse.giflib.web.controller.GifController
Error:(54, 6) java: cannot find symbol
  symbol:   class RequestMapping
  location: class com.teamtreehouse.giflib.web.controller.GifController
Error:(63, 6) java: cannot find symbol
  symbol:   class RequestMapping
  location: class com.teamtreehouse.giflib.web.controller.GifController
Error:(72, 32) java: cannot find symbol
  symbol:   class PathVariable
  location: class com.teamtreehouse.giflib.web.controller.GifController
Error:(71, 6) java: cannot find symbol
  symbol:   class RequestMapping
  location: class com.teamtreehouse.giflib.web.controller.GifController
Error:(79, 6) java: cannot find symbol
  symbol:   class RequestMapping
  location: class com.teamtreehouse.giflib.web.controller.GifController
Error:(89, 30) java: cannot find symbol
  symbol:   class PathVariable
  location: class com.teamtreehouse.giflib.web.controller.GifController
Error:(88, 6) java: cannot find symbol
  symbol:   class RequestMapping
  location: class com.teamtreehouse.giflib.web.controller.GifController
Error:(98, 35) java: cannot find symbol
  symbol:   class PathVariable
  location: class com.teamtreehouse.giflib.web.controller.GifController
Error:(97, 6) java: cannot find symbol
  symbol:   class RequestMapping
  location: class com.teamtreehouse.giflib.web.controller.GifController
Error:(107, 34) java: cannot find symbol
  symbol:   class RequestParam
  location: class com.teamtreehouse.giflib.web.controller.GifController
Error:(106, 6) java: cannot find symbol
  symbol:   class RequestMapping
  location: class com.teamtreehouse.giflib.web.controller.GifController
E:\Users\Jiamin\OneDrive\Documents\Programming\giflib-gradle-builder\src\main\java\com\teamtreehouse\giflib\web\controller\CategoryController.java
Error:(4, 38) java: package org.springframework.stereotype does not exist
Error:(5, 30) java: package org.springframework.ui does not exist
Error:(6, 47) java: package org.springframework.web.bind.annotation does not exist
Error:(7, 47) java: package org.springframework.web.bind.annotation does not exist
Error:(8, 47) java: package org.springframework.web.bind.annotation does not exist
Error:(13, 2) java: cannot find symbol
  symbol: class Controller
Error:(18, 34) java: cannot find symbol
  symbol:   class Model
  location: class com.teamtreehouse.giflib.web.controller.CategoryController
Error:(28, 59) java: cannot find symbol
  symbol:   class Model
  location: class com.teamtreehouse.giflib.web.controller.CategoryController
Error:(38, 35) java: cannot find symbol
  symbol:   class Model
  location: class com.teamtreehouse.giflib.web.controller.CategoryController
Error:(46, 67) java: cannot find symbol
  symbol:   class Model
  location: class com.teamtreehouse.giflib.web.controller.CategoryController
Error:(17, 6) java: cannot find symbol
  symbol:   class RequestMapping
  location: class com.teamtreehouse.giflib.web.controller.CategoryController
Error:(28, 29) java: cannot find symbol
  symbol:   class PathVariable
  location: class com.teamtreehouse.giflib.web.controller.CategoryController
Error:(27, 6) java: cannot find symbol
  symbol:   class RequestMapping
  location: class com.teamtreehouse.giflib.web.controller.CategoryController
Error:(37, 6) java: cannot find symbol
  symbol:   class RequestMapping
  location: class com.teamtreehouse.giflib.web.controller.CategoryController
Error:(46, 37) java: cannot find symbol
  symbol:   class PathVariable
  location: class com.teamtreehouse.giflib.web.controller.CategoryController
Error:(45, 6) java: cannot find symbol
  symbol:   class RequestMapping
  location: class com.teamtreehouse.giflib.web.controller.CategoryController
Error:(53, 6) java: cannot find symbol
  symbol:   class RequestMapping
  location: class com.teamtreehouse.giflib.web.controller.CategoryController
Error:(62, 6) java: cannot find symbol
  symbol:   class RequestMapping
  location: class com.teamtreehouse.giflib.web.controller.CategoryController
Error:(72, 35) java: cannot find symbol
  symbol:   class PathVariable
  location: class com.teamtreehouse.giflib.web.controller.CategoryController
Error:(71, 6) java: cannot find symbol
  symbol:   class RequestMapping
  location: class com.teamtreehouse.giflib.web.controller.CategoryController
E:\Users\Jiamin\OneDrive\Documents\Programming\giflib-gradle-builder\src\main\java\com\teamtreehouse\giflib\config\AppConfig.java
Error:(3, 19) java: package org.hashids does not exist
Error:(4, 52) java: package org.springframework.beans.factory.annotation does not exist
Error:(5, 46) java: package org.springframework.context.annotation does not exist
Error:(6, 46) java: package org.springframework.context.annotation does not exist
Error:(7, 46) java: package org.springframework.context.annotation does not exist
Error:(8, 36) java: package org.springframework.core.env does not exist
Error:(11, 2) java: cannot find symbol
  symbol: class Configuration
Error:(12, 2) java: cannot find symbol
  symbol: class PropertySource
Error:(15, 13) java: cannot find symbol
  symbol:   class Environment
  location: class com.teamtreehouse.giflib.config.AppConfig
Error:(18, 12) java: cannot find symbol
  symbol:   class Hashids
  location: class com.teamtreehouse.giflib.config.AppConfig
Error:(14, 6) java: cannot find symbol
  symbol:   class Autowired
  location: class com.teamtreehouse.giflib.config.AppConfig
Error:(17, 6) java: cannot find symbol
  symbol:   class Bean
  location: class com.teamtreehouse.giflib.config.AppConfig
Error:(19, 20) java: cannot find symbol
  symbol:   class Hashids
  location: class com.teamtreehouse.giflib.config.AppConfig

I might reinstall IntelliJ if that might be helpful.

Jiamin Chen
Jiamin Chen
5,474 Points

FINALLY I got it to work. Apparently the Gradle Installation is broken, and I redownloaded it according to this. I deleted the files and IntelliJ redownloaded everything and now it is all good.

Henry Lin
Henry Lin
11,636 Points

Hi Jiamin,

What version gradle you used for thie project. I am having same issue you did and I followed the stackoverflow but it couldn't solve my problem. Every time the intelliJ automatically download 2.2 -all version of gradle.