我有以下Java泛型问题
我有以下通用类,可以草绘为:
public class MyClass<T> {
AnotherClass<T> another;
OtherClass<T> other;
...
}
Run Code Online (Sandbox Code Playgroud)
where ...表示与案例无关的代码.
因为这个类MyClass<T>并不像确切类型那样重要T(截至目前),但对于两者:
AnotherClass<T>
OtherClass<T>
绝对类型是绝对至关重要的,并且在此基础上将在运行时做出决策.
基于此,类型T不是完全任意的,它可以是类层次结构的实例,也可以是类T_1的层次结构T_2.
正如定义的类,类型T相当于Object但我知道它等同于T_1或T_2
实体之间没有业务关系T_1,T_2因此我没有这样做:
public interface BaseT { ... }
public class T_1 implements BaseT { ... }
public class T_2 implements BaseT { ... }
public class MyClass<T extends BaseT>
Run Code Online (Sandbox Code Playgroud)
澄清为什么使用通用它们是不相关的:
我确定,因为即使他们是不相关的显式(试图)泛型类两种,还有是因为既有隐含关系T_1,并 T_2能够而且将会出现关联到代表的实体MyClass …
我有两个gradle项目:
API Rest 项目公开了一个POST端点,该端点执行一些 Java 代码的运行时编译。
此 Java 代码扩展了一个在业务项目中定义其父级的类。
该代码的编译通过完成InMemoryJavaCompiler在https://github.com/trung/InMemoryJavaCompiler。
根据应用程序的启动方式,会出现两种情况:
启动和调试 API Rest 时IntelliJ工作正常。代码已编译并可以执行。
使用它启动和调试 API Rest 时java -jar不起作用。该 jar 与bootJar任务一起打包。Java 可执行文件来自 JDK
不准确意味着业务项目中定义的InMemoryJavaCompiler类在运行时不被类加载器看到,因此编译失败。
示例堆栈跟踪
2019-01-19 10:33:50.955 ERROR 1636 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.mdkt.compiler.CompilationException: Unable to compile the …Run Code Online (Sandbox Code Playgroud) 方案如下。有一个名为foo(正在大力开发的 API,处于第一个 alpha 阶段)的包,其rst文件是使用sphinx-apidoc.
为了在foo生成这些文件后有更好的文档,需要进行一些编辑。比如说,foo.bar.rst在生成的内容中添加了一些段落sphinx-apidoc
sphinx-apidoc当进行新的呼叫时,如何才能不丢失所有这些信息?当然,我希望反映 API 中的潜在更改,并保留添加的手动信息。
我想MANIFEST在构建jar.
上下文如下:
我有一个gradle基于项目的Spring-boot依赖项。这是一个RESTapi项目。这是我的假设:我尝试过的所有插件都buildJar被Spring依赖项提供的任务覆盖。
所以我的问题如下,
如何通过在项目中定义一个非常简单的 gradle 任务来将提交哈希添加到清单中?
我已经知道如何使用以下任务打印最后一个哈希值
task getHash {
def p1 = 'git rev-parse HEAD'.execute()
p1.waitFor()
println p1.text
}
Run Code Online (Sandbox Code Playgroud)
这是build.gradle详细信息:
buildscript {
ext {
springBootVersion = '2.0.5.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
group = 'com.foo.bar'
version = '0.0.4-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
// …Run Code Online (Sandbox Code Playgroud) java ×3
classloader ×1
compilation ×1
generics ×1
git ×1
gradle ×1
oop ×1
python ×1
spring-boot ×1