English 中文(简体)
中等应用金字塔无法找到我的主要班子。
原标题:Gradle application plugin cannot find my main class
  • 时间:2023-07-10 00:52:40
  •  标签:
  • java
  • gradle
The bounty expires in 7 days. Answers to this question are eligible for a +200 reputation bounty. Scorb wants to draw more attention to this question.

When I try to run ./gradlew run, I am getting the following error...

> Task :run FAILED
Error: Could not find or load main class com.liljaw.desktop.CliTestApp
Caused by: java.lang.ClassNotFoundException: com.liljaw.desktop.CliTestApp

我的梯度项目是一个多模块建设,定义如下......

建设。 梯度

plugins {
    id  application 
}

allprojects {
    group  com.liljaw 
}

subprojects {
    apply plugin:  java 

    sourceCompatibility = 1.8
}

project( :desktop ) {
    dependencies {
        implementation project( :core )
    }
}

application {
    mainClass =  com.liljaw.desktop.CliTestApp 
}

情况。 梯度

rootProject.name =  LilJaw 
include  core 
include  desktop 

主要项目下的桌面文件结构如下......

desktop
├── run.sh
└── src
    └── main
        └── java
            └── com
                └── liljaw
                    └── desktop
                        ├── CliTestApp.java
                        ├── JavaLogInterface.java
                        ├── PcmFloatPlayer.java
                        └── SourceDataLineTest.java

究竟是什么错了,因此我无法从终点站接手申请?

问题回答

我改变了你根基项目的范围。

allprojects {
    group  com.liljaw 
}

subprojects {
    apply plugin:  java 

    sourceCompatibility = 1.8
}

project( :desktop ) {

    apply plugin:  application 

    dependencies {
        implementation project( :core )
    }
    application {
        mainClass =  com.liljaw.desktop.CliTestApp 
    }
}


问题在于,您需要有一些应用的缩略语applicationdesktop。 项目<代码>。

还应当为<代码>desktop 界定<>>>>>> 申请编号。 项目2 项目

在你的情况下,它研究的是根本项目的主要地图集,并且失败。

能够使用<条码>梯度-p desktop/条码”的Im 可在以下屏幕上运行。

“enterography

You should try with adding mainClassName = <your main class with full package path. You can get the details as mentioned here

希望会有所助益。

<>Update:

I tried running the same set of code as yours, and it worked like a charm. Here are things I have : Project Structure

ls
build/  build.gradle  gradle/  gradle.properties  gradlew*  gradlew.bat  settings.gradle  src/


C:.
▒▒▒▒.gradle
▒   ▒▒▒▒7.4
▒   ▒   ▒▒▒▒checksums
▒   ▒   ▒▒▒▒dependencies-accessors
▒   ▒   ▒▒▒▒executionHistory
▒   ▒   ▒▒▒▒fileChanges
▒   ▒   ▒▒▒▒fileHashes
▒   ▒   ▒▒▒▒vcsMetadata
▒   ▒▒▒▒buildOutputCleanup
▒   ▒▒▒▒vcs-1
▒▒▒▒build
▒   ▒▒▒▒classes
▒   ▒   ▒▒▒▒java
▒   ▒       ▒▒▒▒main
▒   ▒           ▒▒▒▒com
▒   ▒               ▒▒▒▒adking
▒   ▒                   ▒▒▒▒desktop
▒   ▒▒▒▒generated
▒   ▒   ▒▒▒▒sources
▒   ▒       ▒▒▒▒annotationProcessor
▒   ▒       ▒   ▒▒▒▒java
▒   ▒       ▒       ▒▒▒▒main
▒   ▒       ▒▒▒▒headers
▒   ▒           ▒▒▒▒java
▒   ▒               ▒▒▒▒main
▒   ▒▒▒▒resources
▒   ▒   ▒▒▒▒main
▒   ▒▒▒▒tmp
▒       ▒▒▒▒compileJava
▒▒▒▒gradle
▒   ▒▒▒▒wrapper
▒▒▒▒src
    ▒▒▒▒main
        ▒▒▒▒java
        ▒   ▒▒▒▒com
        ▒       ▒▒▒▒adking
        ▒           ▒▒▒▒desktop
        ▒▒▒▒resources

这里正在建设。 梯度:

plugins {
    id  application 
}

allprojects {
    group  com.adking 
}

subprojects {
    apply plugin:  java 

    sourceCompatibility = 1.8
}

project( :desktop ) {
    dependencies {
        implementation project( :core )
    }
}

application {
    mainClass =  com.adking.desktop.CliTestApp 
}

和背景。 梯度

rootProject.name =  LilJaw 
include  core 
include  desktop 

On Executing the command ./gradle run Got result as:


> Task :run
Connected to main

BUILD SUCCESSFUL in 1s
3 actionable tasks: 2 executed, 1 up-to-date


因此,我同意,主要地图册实际上并不必要。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签