标签: autofactory

在同一模块中使用时,IntelliJ无法找到生成的源

我正在使用谷歌AutoFactory的注释处理器.我注释SomeClass@AutoFactory和引用的new SomeClassFactory().create()是同一个模块在其他地方.

Maven配置:

我在Maven中添加了必要的依赖:

    <dependency>
        <groupId>com.google.auto.factory</groupId>
        <artifactId>auto-factory</artifactId>
        <version>1.0-beta2</version>
        <optional>true</optional>
    </dependency>
Run Code Online (Sandbox Code Playgroud)

运行时,$ mvn clean compile我看到它target/generated-sources/annotions/somepackage/SomeClassFactory已创建,模块编译没有错误.

IntelliJ配置:

  • Reimport all maven modules
  • Preferences- > Annotation Processors- >Enable annotation processing
  • Rebuild Project

v14.1.4如果我的理解是正确的,那么在我的IDEA()版本中这应该足够了.

编译器首选项 项目结构

我还执行了以下步骤:

  • 已验证该generated-sources文件夹已添加为源Project Structure
  • 已验证Maven首选项Generated sources folders已设置为Detect automatically
  • 验证源是在重建时实际生成的(target首先删除文件夹以确保它是由IntelliJ生成的)
  • 尝试Exclude output paths按照@tilpner的建议在项目结构中禁用
  • 使缓存无效并重新启动
  • 删除.idea文件夹和.iml文件
  • 尝试Phase to be used for …

java intellij-idea maven autofactory

13
推荐指数
1
解决办法
1万
查看次数

Autofac错误-从请求实例的范围中看不到标记匹配“ AutofacWebRequest”的范围

在我的一个Web应用程序中,我有一个使用Autofac的Web服务,其svc文件如下:

<%@ ServiceHost Language="C#" Debug="true" 
Service="MyApp.WebServices.Contracts.Interfaces.IMyWebService, MyApp.WebServices.Contracts" 
Factory="Autofac.Integration.Wcf.AutofacServiceHostFactory, Autofac.Integration.Wcf" %>
Run Code Online (Sandbox Code Playgroud)

我为我的Web服务应用程序注册依赖项,如下所示:

public class IocConfig
{        
    public static void RegisterDependencies()
    {
        var builder = new ContainerBuilder();            

        //web services
        builder.RegisterType<MyWebService>().As<IMyWebService>().InstancePerLifetimeScope();

        var container = builder.Build();

        AutofacHostFactory.Container = container;            
    }
}
Run Code Online (Sandbox Code Playgroud)

从另一个Web应用程序,我也想使用Autofac连接到那些服务,所以我注册了类似的依赖项:

public class IocConfig
{
    //Ioc dependencies for frontend application
    public static void RegisterDependencies()
    {
        var builder = new ContainerBuilder();

        builder.RegisterControllers(typeof(MvcApplication).Assembly);

        builder.RegisterModule<AutofacWebTypesModule>();

        builder
            .Register(c => new ChannelFactory<ISomeWebService>(
                new BasicHttpBinding(),
                new EndpointAddress("http://localhost/MyApp.WebServices/MyWebService.svc")))
            .InstancePerLifetimeScope();

        //register service proxies
        builder.Register(c => c.Resolve<ChannelFactory<IMyWebService>>().CreateChannel())
            .As<IMyWebService>()
            .UseWcfSafeRelease();

        var container = …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc wcf dependency-injection autofac autofactory

3
推荐指数
1
解决办法
1万
查看次数