当我运行"build"
Gradle任务时, 按预期下载所有依赖项,但是它似乎没有发现我有 Java语法的事实错误。
我故意创建了一个缺少;
的语法错误来检查这一点。
为什么会发生这种情况,我该如何解决这个问题?
Java类:
package client;
import org.hibernate.Session;
import util.HibernateUtil;
import entity.Message;
public class HelloWorldClient {
public static void main(String[] args) {
Session session = HibernateUtil.getSessionFactory().openSession();
session.beginTransaction();
Message message = new Message( "Hello World with Hibernate & JPA Annotations" ) //note no ;
session.save(message);
session.getTransaction().commit();
session.close();
}
}
的build.gradle:
group 'test'
version '1.0-SNAPSHOT'
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'application'
mainClassName = "src.client.HelloWorldClient"
repositories {
mavenCentral()
}
dependencies {
compile 'mysql:mysql-connector-java:5.1.38'
compile 'antlr:antlr:2.7.7'
compile 'dom4j:dom4j:1.6.1'
compile 'org.hibernate.common:hibernate-commons-annotations:4.0.4.Final'
compile 'org.hibernate:hibernate-core:4.3.5.Final'
compile 'org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.0.Final'
compile 'org.jboss:jandex:1.1.0.Final'
compile 'org.javassist:javassist:3.18.1-GA'
compile 'org.jboss.logging:jboss-logging:3.1.3.GA'
compile 'org.jboss.logging:jboss-logging-annotations:1.2.0.Beta1'
compile 'org.jboss.spec.javax.transaction:jboss-transaction-api_1.2_spec:1.0.0.Final'
}
Congifuration:
项目结构:
下载依赖项后的输出:
All projects evaluated.
Selected primary task 'build' from project :
Tasks to be executed: [task ':compileJava', task ':processResources', task ':classes', task ':jar', task ':startScripts', task ':distTar', task ':distZip', task ':assemble', task ':compileTestJava', task ':processTestResources', task ':testClasses', task ':test', task ':check', task ':build']
:compileJava (Thread[Daemon worker Thread 4,5,main]) started.
:compileJava
Skipping task ':compileJava' as it has no source files.
:compileJava UP-TO-DATE
:compileJava (Thread[Daemon worker Thread 4,5,main]) completed. Took 0.001 secs.
:processResources (Thread[Daemon worker Thread 4,5,main]) started.
:processResources
Skipping task ':processResources' as it has no source files.
:processResources UP-TO-DATE
:processResources (Thread[Daemon worker Thread 4,5,main]) completed. Took 0.002 secs.
:classes (Thread[Daemon worker Thread 4,5,main]) started.
:classes
Skipping task ':classes' as it has no actions.
:classes UP-TO-DATE
:classes (Thread[Daemon worker Thread 4,5,main]) completed. Took 0.0 secs.
:jar (Thread[Daemon worker Thread 4,5,main]) started.
:jar
Skipping task ':jar' as it is up-to-date (took 0.004 secs).
:jar UP-TO-DATE
:jar (Thread[Daemon worker Thread 4,5,main]) completed. Took 0.006 secs.
:startScripts (Thread[Daemon worker Thread 4,5,main]) started.
:startScripts
Skipping task ':startScripts' as it is up-to-date (took 0.065 secs).
:startScripts UP-TO-DATE
:startScripts (Thread[Daemon worker Thread 4,5,main]) completed. Took 0.067 secs.
:distTar (Thread[Daemon worker Thread 4,5,main]) started.
:distTar
Skipping task ':distTar' as it is up-to-date (took 0.008 secs).
:distTar UP-TO-DATE
:distTar (Thread[Daemon worker Thread 4,5,main]) completed. Took 0.014 secs.
:distZip (Thread[Daemon worker Thread 4,5,main]) started.
:distZip
Skipping task ':distZip' as it is up-to-date (took 0.009 secs).
:distZip UP-TO-DATE
:distZip (Thread[Daemon worker Thread 4,5,main]) completed. Took 0.016 secs.
:assemble (Thread[Daemon worker Thread 4,5,main]) started.
:assemble
Skipping task ':assemble' as it has no actions.
:assemble UP-TO-DATE
:assemble (Thread[Daemon worker Thread 4,5,main]) completed. Took 0.001 secs.
:compileTestJava (Thread[Daemon worker Thread 4,5,main]) started.
:compileTestJava
Skipping task ':compileTestJava' as it has no source files.
:compileTestJava UP-TO-DATE
:compileTestJava (Thread[Daemon worker Thread 4,5,main]) completed. Took 0.002 secs.
:processTestResources (Thread[Daemon worker Thread 4,5,main]) started.
:processTestResources
Skipping task ':processTestResources' as it has no source files.
:processTestResources UP-TO-DATE
:processTestResources (Thread[Daemon worker Thread 4,5,main]) completed. Took 0.002 secs.
:testClasses (Thread[Daemon worker Thread 4,5,main]) started.
:testClasses
Skipping task ':testClasses' as it has no actions.
:testClasses UP-TO-DATE
:testClasses (Thread[Daemon worker Thread 4,5,main]) completed. Took 0.001 secs.
:test (Thread[Daemon worker Thread 4,5,main]) started.
:test
Skipping task ':test' as it has no source files.
:test UP-TO-DATE
:test (Thread[Daemon worker Thread 4,5,main]) completed. Took 0.001 secs.
:check (Thread[Daemon worker Thread 4,5,main]) started.
:check
Skipping task ':check' as it has no actions.
:check UP-TO-DATE
:check (Thread[Daemon worker Thread 4,5,main]) completed. Took 0.001 secs.
:build (Thread[Daemon worker Thread 4,5,main]) started.
:build
Skipping task ':build' as it has no actions.
:build UP-TO-DATE
:build (Thread[Daemon worker Thread 4,5,main]) completed. Took 0.001 secs.
BUILD SUCCESSFUL
Total time: 0.316 secs
Stopped 0 compiler daemon(s).
22:06:01: External task execution finished 'build --info'.
新项目结构:
答案 0 :(得分:1)
src/main/java
下没有任何源文件。移动客户端,域,实体包在那里,你会得到编译错误:)
答案 1 :(得分:1)
跳过任务':compileJava',因为它没有源文件。
将您的来源移至src/main/java
或调整您的构建文件。
见23.4 https://docs.gradle.org/current/userguide/java_plugin.html