I am trying to use Spring boot in my gradle project. But when I try to clean build, it gives the following error (only relevant stacktrace):
Caused by: org.gradle.api.internal.plugins.PluginApplicationException: Failed to apply plugin [id 'spring-boot']
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.applyPlugin(DefaultObjectConfigurationAction.java:117)
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.access$200(DefaultObjectConfigurationAction.java:36)
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction$3.run(DefaultObjectConfigurationAction.java:80)
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.execute(DefaultObjectConfigurationAction.java:131)
at org.gradle.api.internal.project.AbstractPluginAware.apply(AbstractPluginAware.java:37)
at org.gradle.api.Project$apply.call(Unknown Source)
at org.gradle.api.internal.project.ProjectScript.apply(ProjectScript.groovy:34)
at org.gradle.api.Script$apply.callCurrent(Unknown Source)
at build_2o7juvjo3110jmss6k1iqcfrir.run(/Users/AlmasBarday/bos-api/build.gradle:13)
at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:52)
... 57 more
Caused by: org.gradle.api.plugins.UnknownPluginException: Plugin with id 'spring-boot' not found.
at org.gradle.api.internal.plugins.DefaultPluginRegistry.getTypeForId(DefaultPluginRegistry.java:91)
at org.gradle.api.internal.plugins.DefaultPluginContainer.getTypeForId(DefaultPluginContainer.java:183)
at org.gradle.api.internal.plugins.DefaultPluginContainer.apply(DefaultPluginContainer.java:103)
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.applyPlugin(DefaultObjectConfigurationAction.java:115)
My build.gradle has the following:
apply plugin: 'java'
apply plugin: 'maven-publish'
apply plugin: 'spring-boot'
dependencies {
compile 'org.slf4j:slf4j-api:1.7.5'
compile 'net.sourceforge.jexcelapi:jxl:2.6.12'
compile 'com.qas:proweb:1.0.0'
compile "org.springframework:spring-beans:$springVersion"
compile "org.springframework:spring-jdbc:$springVersion"
compile "org.springframework:spring-web:$springVersion"
compile "org.springframework.boot:spring-boot-starter-web:1.2.7.RELEASE"
testCompile 'junit:junit:4.11'
}
I searched the internet and tried solutions posted to similar problems, but nothing seems to work. Also, I am able to build another gradle-springboot project without any problems.
Any help appreciated.
You've forgot to configure you buildscript, by adding it's dependencies part. You can do it, by addin this to your build.script:
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.5.RELEASE")
}
}
Here you're configuring your buildscript dependencies, to make it possible for Gradle to apply the plugin. But that does not mean, that you can delete dependency for you sources. They are still use to be there, like you already have:
dependencies {
...
compile "org.springframework:spring-beans:$springVersion"
compile "org.springframework:spring-jdbc:$springVersion"
compile "org.springframework:spring-web:$springVersion"
compile "org.springframework.boot:spring-boot-starter-web:1.2.7.RELEASE"
}
plugins { id "org.springframework.boot" version "2.0.1.RELEASE" }
The above script should also be added to build.gradle at the top level to make it work.
Related
I am using gradle install and surprisingly my jar in /m2 repository not udpating.
Even though I deleted the folder and then did gradle install, I am unable to see the latest jar. The old jar is again getting created.
I did gradle install just now and see what happened (no errors) :
Below is my build.gradle
apply plugin: 'java-library'
apply plugin: 'eclipse'
apply plugin: 'maven'
group = 'bt'
version = '1.0'
repositories{
jcenter()
mavenCentral()
mavenLocal()
}
dependencies {
compile('bt:daoconfig:1.0')
compile('bt:common:1.0')
testCompile 'org.hsqldb:hsqldb:2.2.8'
testCompile 'org.powermock:powermock-mockito-release-full:1.6.4'
testCompile 'junit:junit:4.12'
testCompile 'org.springframework.boot:spring-boot-starter-test:1.5.2.RELEASE'
}
Kindly let me know what wrong i am doing?
thanks
I used gradle clean , then gradle install. It got updated. Thanks
I'm trying to setup the gradle-kotlin-plugin locally, but it doesnt work at all. Im using Gradle 4.9 and Kotlin version 1.2.71. The Gradle sync fails and this exceptions is thrown:
org/jetbrains/kotlin/cli/common/PropertiesKt
NoClassDefFoundError: org/jetbrains/kotlin/cli/common/PropertiesKt
Im put all needed resources into the directory /lib/kotlin, meaning kotlin-gradle-plugin-1.2.71.jar, kotlin-stdlib-1.2.70.jar,kotlin-stdlib-1.2.70.pom,kotlin-stdlib-common-1.2.70.jar,kotlin-stdlib-common-1.2.70.pom.
If i set the repo to url "https://plugins.gradle.org/m2/" everything is working fine(i always want to load the plugin from the local file and NOT from the online repo).
The other kotlin dependencies are also included.
build.gradle
buildscript {
ext.kotlin_version = '1.2.71'
repositories {
flatDir dirs: '/lib/kotlin'
mavenLocal()
maven{
url uri('lib/kotlin')
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
...
allprojects {
apply plugin: 'java'
apply plugin: 'application'
apply plugin: "kotlin"
..
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
Edit:
Now the plugin is working but Kotlin is not compiling and is telling me:
Could not perform incremental compilation: Could not connect to Kotlin compile daemon
Could not connect to kotlin daemon. Using fallback strategy.
Exception in thread "main" java.lang.NoClassDefFoundError: kotlin/jvm/internal/Intrinsics
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler$Companion.main(K2JVMCompiler.kt)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.main(K2JVMCompiler.kt)
Caused by: java.lang.ClassNotFoundException: kotlin.jvm.internal.Intrinsics
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 2 more
Try adding below dependency also
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
Do clean your ~/.gradle directory
I want to add the tomcat plugin to my gradle build, but the plugin cannot be found , gradle shows the error
Plugin with id 'com.bmuschko.tomcat' not found.
I followed the steps on the github page of this plugin, but it does not work.
In my project I have general build.gradle in this I am loading my project.gradle in this I defined the tomcat-plugin configuration.
build.gradle
apply plugin: 'java'
apply plugin: 'maven'
sourceCompatibility = 1.8
ext {
debug = false
}
apply from: 'project.gradle'
group = myGroup
version = myVersion + '-SNAPSHOT'
project.gradle
//https://github.com/bmuschko/gradle-tomcat-plugin
buildscript {
repositories {
jcenter();
}
dependencies {
classpath 'com.bmuschko:gradle-tomcat-plugin:2.4.2'
}
}
apply plugin: "com.bmuschko.tomcat"
apply plugin: "idea"
apply plugin: "project-report"
apply plugin: "war"
I can ensure that dependencies can be resolved from my machine, because other gradle projects work, so that it should not be a network issue, there is no proxy configuration etc.
You have to put buildscript{} into your main build.gradle. The buildscript process is outside the regular Gradle build. Same applies to plugins{} as well (since they are equivalent.)
So if you put
buildscript {
repositories {
jcenter();
}
dependencies {
classpath 'com.bmuschko:gradle-tomcat-plugin:2.4.2'
}
}
into your build.gradle, it would work.
[Update]
I have created a sample gradle project with the fix in it.
And the TravisCI build is here.
Or you may try using the plugin type:
apply plugin: com.bmuschko.gradle.tomcat.TomcatPlugin
instead of
apply plugin: "com.bmuschko.tomcat"
in your project.gradle file.
I've followed the instructions to creating a Gradle project using JMonkey but I have been unable to get any of the assets to load as stated in the tutorial:
http://wiki.jmonkeyengine.org/doku.php/jme3:beginner:hello_asset
My build.gradle looks like this:
apply plugin: 'java'
apply plugin: 'eclipse'
sourceCompatibility = 1.8
version = '1.0'
jar {
manifest {
attributes 'Implementation-Title': 'Gradle Quickstart', 'Implementation-Version': version
}
}
repositories {
mavenCentral()
maven {
url 'http://updates.jmonkeyengine.org/maven'
}
}
dependencies {
compile 'com.jme3:jme3-core:3.0.+'
compile 'com.jme3:jme3-effects:3.0.+'
compile 'com.jme3:jme3-networking:3.0.+'
compile 'com.jme3:jme3-plugins:3.0.+'
compile 'com.jme3:jme3-jogg:3.0.+'
compile 'com.jme3:jme3-terrain:3.0.+'
compile 'com.jme3:jme3-blender:3.0.+'
compile 'com.jme3:jme3-jbullet:3.0.+'
compile 'com.jme3:jme3-niftygui:3.0.+'
compile 'com.jme3:jme3-desktop:3.0.+'
compile 'com.jme3:jme3-lwjgl:3.0.+'
}
The sample was created from the wiki: http://wiki.jmonkeyengine.org/doku.php/jme3:maven
However the wiki makes no references to assets or how to build them.
After looking through the internet I found that the jar that I'm looking for is the jME3-testdata.jar. According to this conversation: http://hub.jmonkeyengine.org/t/official-maven-repo-for-jme3-0-stable-available-please-test/30571
It was a deliberate decision not to include the test data jar. Because of this, I went ahead and manually downloaded the missing jar and added it to my classpath.
I'm trying to add jacoco support to my gradle project, but when I add the jacoco plugin, it gives me an error.
Here is my gradle.build
task wrapper(type: Wrapper) { gradleVersion = '1.11' }
apply plugin: 'java'
apply plugin: 'groovy'
apply plugin: 'war'
apply plugin: 'eclipse'
apply plugin: 'eclipse-wtp'
apply plugin: 'application'
apply plugin: 'project-report'
apply plugin: 'jacoco'
eclipse {
classpath { downloadSources=true }
}
eclipse.classpath.file {
// Classpath entry for Eclipse which changes the order of classpathentries; otherwise no sources for 3rd party jars are shown
withXml { xml ->
def node = xml.asNode()
node.remove( node.find { it.#path == 'org.eclipse.jst.j2ee.internal.web.container' } )
node.appendNode( 'classpathentry', [ kind: 'con', path: 'org.eclipse.jst.j2ee.internal.web.container', exported: 'true'])
}
}
tasks.withType(Compile) { options.encoding = 'UTF-8' }
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
providedCompile 'javax.servlet:servlet-api:2.5'
runtime 'javax.servlet:jstl:1.1.2'
compile 'org.springframework.batch:spring-batch-core:2.2.5.RELEASE'
compile 'org.springframework:spring-webmvc:4.0.2.RELEASE'
compile 'org.springframework:spring-jdbc:4.0.2.RELEASE'
compile 'org.springframework:spring-orm:4.0.2.RELEASE'
compile 'org.springframework.data:spring-data-mongodb:1.4.0.RELEASE'
compile 'org.springframework.security:spring-security-web:3.2.1.RELEASE'
compile 'org.springframework.security:spring-security-config:3.2.1.RELEASE'
compile 'org.slf4j:slf4j-simple:1.6.1'
compile 'org.codehaus.groovy:groovy-all:2.2.0'
compile 'org.mongodb:mongo-java-driver:2.11.4'
compile 'c3p0:c3p0:0.9.1.2'
compile 'org.hibernate:hibernate-core:4.3.4.Final'
compile 'org.hibernate:hibernate-ehcache:4.3.4.Final'
compile 'org.hsqldb:hsqldb:2.0.0'
compile 'com.google.guava:guava:16.0'
compile 'commons-io:commons-io:2.4'
compile 'com.google.code.gson:gson:2.2.4'
compile 'org.codehaus.jackson:jackson-core-asl:1.9.13'
compile 'org.codehaus.jackson:jackson-mapper-asl:1.9.13'
testCompile 'junit:junit:4.11'
testCompile 'commons-collections:commons-collections:3.2'
testCompile 'org.springframework:spring-test:4.0.2.RELEASE'
testCompile 'org.codehaus.groovy:groovy-all:2.2.0'
testCompile 'de.flapdoodle.embed:de.flapdoodle.embed.mongo:1.35'
testCompile 'org.springframework.batch:spring-batch-test:2.2.5.RELEASE'
compile localGroovy()
}
test {
testLogging { // Show that tests are run in the command-line output
events 'started', 'passed' }
exclude 'com/bambilon/All*'
exclude 'com/bambilon/**/slow/*'
}
and when I run refresh dependencies in Eclipse, it gives me this error:
Caused by: org.gradle.api.plugins.UnknownPluginException: Plugin with id 'jacoco' not found.
at org.gradle.api.internal.plugins.DefaultPluginRegistry.getTypeForId(DefaultPluginRegistry.java:86)
at org.gradle.api.internal.plugins.DefaultProjectsPluginContainer.getTypeForId(DefaultProjectsPluginContainer.java:102)
at org.gradle.api.internal.plugins.DefaultProjectsPluginContainer.apply(DefaultProjectsPluginContainer.java:37)
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.applyPlugin(DefaultObjectConfigurationAction.java:101)
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.access$200(DefaultObjectConfigurationAction.java:32)
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction$3.run(DefaultObjectConfigurationAction.java:72)
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.execute(DefaultObjectConfigurationAction.java:114)
at org.gradle.api.internal.project.AbstractProject.apply(AbstractProject.java:846)
at org.gradle.api.Project$apply.call(Unknown Source)
at org.gradle.api.internal.project.ProjectScript.apply(ProjectScript.groovy:34)
at org.gradle.api.Script$apply.callCurrent(Unknown Source)
Please help, thanks!
I am not quite sure which version introdueced jacoco plugin but with Gradle 2.x it for sure works. If you have a $buildDir/jacoco folder after running gradle build, you can be sure that it works. More information on http://www.gradle.org/docs/current/userguide/jacoco_plugin.html.
I have also got the same problem , I have set the gradle path in eclipse .It sloved for me.To set the path
Eclipse -Window->preference-type Gardle
Click on folder radio button , and set path to gradle folder located in your system.