停止Spring MVC注释处理(Stop Spring MVC annotations processing)
我需要停止在接口上处理Spring MVC注释,但是应该创建这个接口的bean。 例如,我使用MVC REST注释共享Api接口,Controller实现此Api。 在其他项目中,我基于接口创建REST客户端(通过处理注释)。 但是,当我创建客户端时,Spring将接口视为返回类型并在其中处理注释。 所以,当我创建REST客户端时,我需要停止注释处理,但是对于控制器注释应该可以工作(现在它们工作正常)。
@RequestMapping("/resource1") public interface Api { @RequestMapping(method = RequestMethod.POST) Resource1 getResource1(); } @RestController public class Controller implements Api { @Override public Resource1 getResource1() { return null; } } @Configuration public class Config { @Bean public Api api() { return RestClientFactory.createRestClientBasedOnAnnotations(Api.class); } }
I need to stop processing of Spring MVC annotations on interface, but bean for this interface should be created. e.g. I have shared Api interface with MVC REST annotations, Controller implements this Api. In other project I create REST client based on interface (by processing annotations). But when I create client, Spring sees interface as return type and process annotations inside it. So, I need to stop annotations processing when I create REST client, but for controller annotations should work (now they work OK).
@RequestMapping("/resource1") public interface Api { @RequestMapping(method = RequestMethod.POST) Resource1 getResource1(); } @RestController public class Controller implements Api { @Override public Resource1 getResource1() { return null; } } @Configuration public class Config { @Bean public Api api() { return RestClientFactory.createRestClientBasedOnAnnotations(Api.class); } }
原文:https://stackoverflow.com/questions/37523595
最满意答案
目前,构建脚本只能通过HTTP分发(
apply from: "http://..."
)。 但是,二进制插件(即实现org.gradle.api.Plugin
接口的类)可以使用与构建脚本几乎相同的语法,并且可以作为Jar分发。Currently, build scripts can only be distributed via HTTP (
apply from: "http://..."
). However, a binary plugin (i.e. a class implementing theorg.gradle.api.Plugin
interface) can use almost the same syntax as a build script, and can be distributed as a Jar.
相关问答
更多-
TCP/IP模型是一个________。[2023-10-02]
a -
默认项目名称取自存储项目的目录。不要明确更改jar名称,而应将项目名称设置为您的构建的正确名称。 目前这在build.gradle文件中是不可能的。 相反,您必须在根目录中创建settings.gradle文件。 这个settings.gradle文件应该包含这一行代码: rootProject.name = 'project1' The default project name is taken from the directory the project is stored in. Instead o ...
-
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
可执行的jar文件只是一个包含其清单中的Main-Class条目的jar文件。 所以你只需要配置jar任务 ,以便在其清单中添加这个条目: jar { manifest { attributes 'Main-Class': 'com.foo.bar.MainClass' } } 您可能还需要在清单中添加类路径条目,但这样做将以相同的方式完成。 请参阅http://docs.oracle.com/javase/tutorial/deployment/jar/manifesti ...
-
是否可以将Gradle脚本作为插件打包到Jar中(Is it possible to package Gradle scripts as a plugin into a Jar)[2022-04-26]
目前,构建脚本只能通过HTTP分发( apply from: "http://..." )。 但是,二进制插件(即实现org.gradle.api.Plugin接口的类)可以使用与构建脚本几乎相同的语法,并且可以作为Jar分发。 Currently, build scripts can only be distributed via HTTP (apply from: "http://..."). However, a binary plugin (i.e. a class implementing the ... -
ClassLoader.getResourceAsStream()是一个实例方法,而不是静态方法。 (我希望Groovy以这种或那种方式告诉你。)尝试使用getClass().classloader.getResourceAsStream()或buildscript.classLoader.getResourceAsStream() 。 ClassLoader.getResourceAsStream() is an instance method, not a static method. (I'd exp ...
-
使用稍微修改过的代码版本,我就可以获得模型的值。 的build.gradle: group 'com.jbirdvegas.so' version '1.0-SNAPSHOT' apply plugin: 'groovy' // apply our plugin... calls SamplePlugin#apply(Project) apply plugin: 'sample' repositories { mavenCentral() } dependencies { compil ...
-
目前,Gradle无法为每个依赖项指定不同的repo配置。 之前已经要求并讨论过这个问题。 还有一个开放且未解决的Jira 。 还请看: 1 2 Specifying different repo configuration per dependency is currently not possible with Gradle. This has been requested and discussed before. There is an open and unresolved Jira as wel ...
-
如何打包Gradle插件?(How to package a Gradle plugin?)[2024-03-07]
implementation-class应该指向实现Plugin<>主要插件类 例如,在jmeter-gradle-plugin/src/main/resources/META-INF/gradle-plugins/net.foragerr.FooPlugin.properties implementation-class=net.foragerr.soanswers.FooPluginImpl 然后我将实现一个类: package net.foragerr.soanswers class FooPlu ... -
在运行Gradle的PMD插件时在jar路径中包含jar(Including jar in classpath when running Gradle's PMD plugin)[2022-03-28]
配置pmd { ... } ,您正在配置扩展 。 有时您可能需要下拉到任务级别并配置tasks.pmd { ... } 。 (具有相同名称的扩展和任务是代码质量和IDE扩展/任务使用的常见模式。)向PMD类路径添加内容的最简单方法是: dependencies { pmd ... } 我没有尝试,如果这适用于添加外部规则,但它可能。 When you are configuring pmd { ... }, you are configuring the extension. Sometimes ...