Не удалось найти метод compile() для аргументов
Я пытаюсь выполнить несколько сценариев .sql
, а затем развернуть веб-приложение с помощью gradle tomcat plugin
.
Но когда я пытаюсь запустить gradle
, у меня есть ошибка
![enter image description here]()
Мой buildscript
выглядит следующим образом
buildscript {
//repository location
repositories {
mavenCentral()
jcenter()
}
//dependencies
//did not divide them into runtime&compile
dependencies {
//aspectJ dependencies
compile 'org.aspectj:aspectjlib:1.6.2'
compile 'org.aspectj:aspectjrt:1.7.4'
compile 'org.aspectj:aspectjweaver:1.7.4'
//servlet
compile 'javax.servlet:javax.servlet-api:3.0.1'
//jdbc postresql
compile 'org.postgresql:postgresql:9.2-1004-jdbc4'
//commons dbcp
compile 'commons-dbcp:commons-dbcp:1.2.2'
//spring & spring MVC dependencies
compile 'org.springframework:spring-core:' + spring_version
compile 'org.springframework:spring-web:' + spring_version
compile 'org.springframework:spring-webmvc:' + spring_version
compile 'org.springframework:spring-jdbc:' + spring_version
compile 'org.springframework:spring-aspects:' + spring_version
//spring security
compile 'org.springframework.security:spring-security-core:' + spring_security_version
compile 'org.springframework.security:spring-security-web:' + spring_security_version
compile 'org.springframework.security:spring-security-config:' + spring_security_version
//JSTL
compile 'jstl:jstl:1.2'
//slf4j-log4j
compile 'org.slf4j:slf4j-api:1.7.0'
compile 'org.slf4j:slf4j-log4j12:1.7.0'
compile 'log4j:log4j:1.2.17'
//mybatis
compile 'org.mybatis:mybatis:3.2.4'
compile 'org.mybatis:mybatis-spring:1.2.2'
//gson
compile 'com.google.code.gson:gson:2.2.4'
//validation jsr303
compile 'javax.validation:validation-api:1.0.0.GA'
//junit4(test?)
compile 'junit:junit:4.11'
//spring test(test?)
compile 'org.springframework:spring-test:' + spring_version
//java mail
compile 'javax.mail:mail:1.4'
//tomcat plugin
def tomcatVersion = '7.0.53'
tomcat "org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}",
"org.apache.tomcat.embed:tomcat-embed-logging-juli:${tomcatVersion}"
tomcat("org.apache.tomcat.embed:tomcat-embed-jasper:${tomcatVersion}") {
exclude group: 'org.eclipse.jdt.core.compiler', module: 'ecj'
}
//additional classpath
classpath 'org.gradle.api.plugins:gradle-tomcat-plugin:1.2.3'
classpath 'org.postgresql:postgresql:9.2-1004-jdbc4'
}
}
В build.gradle
также есть несколько задач и несколько apply plugin
.
Какая проблема? Полная трассировка стека
![enter image description here]()
Мой build.gradle
находится в папке проекта.
Ответы
Ответ 1
Строка script смешивает зависимости buildscript
(т.е.
- зависимости самой сборки; обычно это означает Gradle плагины
- с регулярными зависимостями (т.е. зависимостями компилируемого/выполняемого кода).
2 нужно перейти в dependencies { ... }
, а не в buildscript { dependencies { ... } }
.
Все, кроме зависимостей classpath
, являются регулярными зависимостями.
Ответ 2
Я иногда получаю эту ошибку после того, как Android Studio выполняет некоторую операцию, которая пытается автоматически добавить вещи в файл build.gradle, а затем она помещает строки кода в блок зависимостей, которые заканчиваются кавычками или двойными кавычками. Итак, я заканчиваю так:
def gpsVersion = '9.4.0'
compile "com.google.android.gms:play-services-wearable:${gpsVersion}" compile "com.google.android.gms:play-services-places:${gpsVersion}"
И как вы можете видеть, похоже, что метод compile
теперь имеет много аргументов. Зафиксируйте межстрочный интервал и повторите попытку, чтобы исправить его.