1,在abp官网下载的模板(asp.net+ef)写Application层的时候需要使用AutoMapper。结果ObjectMapper一直为null

解决:需要在当前项目的Module依赖AbpAutoMapperModule

2,Linq Include扩展方法需要引用EntityFramework.dll

3,ToListAsync扩展方法需要引用using Abp.Linq.Extensions;

4,手动搭建abp2.x老是出现System.Collections.Immutable1.2.1.0找不到

解决:

①编辑项目web.config改为(这个可以不管)

  1. <dependentAssembly>
  2. <assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
  3. <bindingRedirect oldVersion="0.0.0.0-1.2.1.0" newVersion="1.2.1.0" />
  4. </dependentAssembly>

②编辑项目工程文件(例如Demo.Web.csproj文件)

案例下载:http://pan.baidu.com/s/1kU7By31

5,创建租户(独立数据库)报MSDTC 不可用

解决方案:

打开windows服务开启Distributed Transaction Coordinator服务

6,单元测试时老是报个错:

解决:

单元测试Module需要依赖AbpTestBaseModule

7,运行模板项目报错

解决办法:删除项目下的bin目录,然后重新编译就好了

8, 把Abp.Zero.Common添加到项目报错

解决方法:

在Abp.Zero.Common.csproj文件中删除

9,本地化失效

解决方法:需要把xml设置为嵌入的资源

10,更改提示变成中文 

扩展本地化文件

在Ousutec.Duty.Core中的DutyLocalizationConfigurer的Configure方法加上扩展配置

  1. using Abp.Configuration.Startup;
  2. using Abp.Localization.Dictionaries;
  3. using Abp.Localization.Dictionaries.Xml;
  4. using Abp.Localization.Sources;
  5. using Abp.Reflection.Extensions;
  6.  
  7. namespace Ousutec.Duty.Localization
  8. {
  9. public static class DutyLocalizationConfigurer
  10. {
  11. public static void Configure(ILocalizationConfiguration localizationConfiguration)
  12. {
  13. localizationConfiguration.Sources.Add(
  14. new DictionaryBasedLocalizationSource(DutyConsts.LocalizationSourceName,
  15. new XmlEmbeddedFileLocalizationDictionaryProvider(
  16. typeof(DutyLocalizationConfigurer).GetAssembly(),
  17. "Ousutec.Duty.Localization.SourceFiles"
  18. )
  19. )
  20. );
  21.  
  22. localizationConfiguration.Sources.Extensions.Add(
  23. new LocalizationSourceExtensionInfo("AbpWeb",
  24. new XmlEmbeddedFileLocalizationDictionaryProvider(
  25. typeof(DutyLocalizationConfigurer).GetAssembly(),
  26. "Ousutec.Duty.Localization.AbpWebExtensions"
  27. )
  28. )
  29. );
  30. }
  31. }
  32. }

DutyLocalizationConfigurer

将Abp.Web.Common源码的AbpWeb-zh-Hans.xml复制到Ousutec.Duty.Core项目中。并嵌入资源

11,关于自动注册依赖

约定名称必须一直,例如

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using Castle.Core.Logging;
  5. using Ousutec.Duty.Common;
  6. using Newtonsoft.Json;
  7.  
  8. using Abp.Dependency;
  9. using Ousutec.Duty.DutyCmds;
  10. using Abp.AutoMapper;
  11.  
  12. namespace Ousutec.Duty.RabbitMqListeners
  13. {
  14. public class DutyCmdListener : IDutyCmdListener, ITransientDependency
  15. {
  16. private readonly ILogger _logger;
  17. private readonly IDutyCmdAppService _dutyCmdAppService;
  18. public DutyCmdListener(ILogger logger, IDutyCmdAppService dutyCmdAppService)
  19. {
  20. _logger = logger;
  21. _dutyCmdAppService = dutyCmdAppService;
  22. }
  23.  
  24. public void ProcessMsg(DutyCmdMessage msg)
  25. {
  26. _logger.Info(JsonConvert.SerializeObject(msg));
  27. _dutyCmdAppService.Add(msg.DutyCmdDtos.MapTo<IEnumerable<Addinput>>());
  28. }
  29. }
  30. }

DutyCmdListener

不一致会 报找不到依赖异常

12,Swagger CustomSchemaIds错误

Conflicting schemaIds: Identical schemaIds detected for types Ousutec.Duty.DutyRecords.AddInput and Ousutec.Duty.DutyDevSettings.AddInput. See config settings - "CustomSchemaIds" for a workaround

解决方法:  options.CustomSchemaIds(t => t.FullName);

  1. // Swagger - Enable this line and the related lines in Configure method to enable swagger UI
  2. services.AddSwaggerGen(options =>
  3. {
  4. options.SwaggerDoc("v1", new Info { Title = "Duty API", Version = "v1" });
  5. options.DocInclusionPredicate((docName, description) => true);
  6.  
  7. options.CustomSchemaIds(t => t.FullName);
  8. // Define the BearerAuth scheme that's in use
  9. options.AddSecurityDefinition("bearerAuth", new ApiKeyScheme()
  10. {
  11. Description = "JWT Authorization header using the Bearer scheme. Example: \"Authorization: Bearer {token}\"",
  12. Name = "Authorization",
  13. In = "header",
  14. Type = "apiKey"
  15. });
  16. // Assign scope requirements to operations based on AuthorizeAttribute
  17. options.OperationFilter<SecurityRequirementsOperationFilter>();
  18. });

Startup

13,接口返回参数命名,忽略abp框架设置的命名规则

  1. using System;
  2. using System.Linq;
  3. using System.Reflection;
  4. using Microsoft.AspNetCore.Mvc;
  5. using Microsoft.AspNetCore.Builder;
  6. using Microsoft.AspNetCore.Hosting;
  7. using Microsoft.AspNetCore.Mvc.Cors.Internal;
  8. using Microsoft.Extensions.Configuration;
  9. using Microsoft.Extensions.DependencyInjection;
  10. using Castle.Facilities.Logging;
  11. using Swashbuckle.AspNetCore.Swagger;
  12. using Abp.AspNetCore;
  13. using Abp.Castle.Logging.Log4Net;
  14. using Abp.Extensions;
  15. using Ousu.DataCollection.Attendance.Authentication.JwtBearer;
  16. using Ousu.DataCollection.Attendance.Configuration;
  17. using Ousu.DataCollection.Attendance.Identity;
  18. using Ousu.DataCollection.Attendance.Common;
  19. using Abp.AspNetCore.SignalR.Hubs;
  20. using Ousu.DataCollection.Attendance.AttendanceCmds;
  21. using Abp.Dependency;
  22. using Castle.Windsor.MsDependencyInjection;
  23. using Aliyun.OSS;
  24. using Castle.Core.Logging;
  25. using Abp.Json;
  26. using Newtonsoft.Json.Serialization;
  27. using Abp;
  28.  
  29. namespace Ousu.DataCollection.Attendance.Web.Host.Startup
  30. {
  31. public class Startup
  32. {
  33. private const string _defaultCorsPolicyName = "localhost";
  34.  
  35. private readonly IConfigurationRoot _appConfiguration;
  36.  
  37. public Startup(IHostingEnvironment env)
  38. {
  39. _appConfiguration = env.GetAppConfiguration();
  40. }
  41.  
  42. public IServiceProvider ConfigureServices(IServiceCollection services)
  43. {
  44.  
  45. // MVC
  46. services.AddMvc(
  47. options =>
  48. {
  49. options.Filters.Add(new CorsAuthorizationFilterFactory(_defaultCorsPolicyName));
  50. }
  51. );
  52.  
  53. IdentityRegistrar.Register(services);
  54. AuthConfigurer.Configure(services, _appConfiguration);
  55.  
  56. services.AddSignalR();
  57.  
  58. // Configure CORS for angular2 UI
  59. services.AddCors(
  60. options => options.AddPolicy(
  61. _defaultCorsPolicyName,
  62. builder => builder
  63. .WithOrigins(
  64. // App:CorsOrigins in appsettings.json can contain more than one address separated by comma.
  65. _appConfiguration["App:CorsOrigins"]
  66. .Split(",", StringSplitOptions.RemoveEmptyEntries)
  67. .Select(o => o.RemovePostFix("/"))
  68. .ToArray()
  69. )
  70. .AllowAnyHeader()
  71. .AllowAnyMethod()
  72. .AllowCredentials()
  73. )
  74. );
  75.  
  76. // Swagger - Enable this line and the related lines in Configure method to enable swagger UI
  77. services.AddSwaggerGen(options =>
  78. {
  79. options.SwaggerDoc("v1", new Info { Title = "Attendance API", Version = "v1" });
  80. options.DocInclusionPredicate((docName, description) => true);
  81.  
  82. options.CustomSchemaIds(t => t.FullName);
  83. // Define the BearerAuth scheme that's in use
  84. options.AddSecurityDefinition("bearerAuth", new ApiKeyScheme()
  85. {
  86. Description = "JWT Authorization header using the Bearer scheme. Example: \"Authorization: Bearer {token}\"",
  87. Name = "Authorization",
  88. In = "header",
  89. Type = "apiKey"
  90. });
  91. // Assign scope requirements to operations based on AuthorizeAttribute
  92. options.OperationFilter<SecurityRequirementsOperationFilter>();
  93. });
  94.  
  95. //去除abp框架自带的命名规则
  96. services.PostConfigure<MvcJsonOptions>(options =>
  97. {
  98. options.SerializerSettings.ContractResolver = new AbpContractResolver();
  99. });
  100.  
  101. // Configure Abp and Dependency Injection
  102. return services.AddAbp<AttendanceWebHostModule>(
  103. // Configure Log4Net logging
  104. options =>
  105. {
  106. options.IocManager.IocContainer.AddFacility<LoggingFacility>(f => f.UseAbpLog4Net().WithConfig("log4net.config"));
  107. }
  108. );
  109. }
  110.  
  111. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
  112. {
  113. app.UseAbp(options => { options.UseAbpRequestLocalization = false;}); // Initializes ABP framework.
  114.  
  115. app.UseCors(_defaultCorsPolicyName); // Enable CORS!
  116.  
  117. app.UseStaticFiles();
  118.  
  119. app.UseAuthentication();
  120.  
  121. app.UseAbpRequestLocalization();
  122.  
  123. app.UseSignalR(routes =>
  124. {
  125. routes.MapHub<AbpCommonHub>("/signalr");
  126. });
  127.  
  128. app.UseMvc(routes =>
  129. {
  130. routes.MapRoute(
  131. name: "defaultWithArea",
  132. template: "{area}/{controller=Home}/{action=Index}/{id?}");
  133.  
  134. routes.MapRoute(
  135. name: "default",
  136. template: "{controller=Home}/{action=Index}/{id?}");
  137. });
  138.  
  139. // Enable middleware to serve generated Swagger as a JSON endpoint
  140. app.UseSwagger();
  141. // Enable middleware to serve swagger-ui assets (HTML, JS, CSS etc.)
  142. app.UseSwaggerUI(options =>
  143. {
  144. options.SwaggerEndpoint(_appConfiguration["App:ServerRootAddress"] + "/swagger/v1/swagger.json", "Attendance API V1");
  145. options.IndexStream = () => Assembly.GetExecutingAssembly()
  146. .GetManifestResourceStream("Ousu.DataCollection.Attendance.Web.Host.wwwroot.swagger.ui.index.html");
  147. }); // URL: /swagger
  148. }
  149. }
  150. }

去除abp框架自带的命名规则

14,不使用abp框架自带的返回格式

在类或者方法上加上[DontWrapResult]特性

学习ABP遇到的问题汇总的更多相关文章

  1. ABP入门系列(1)——学习Abp框架之实操演练

    作为.Net工地搬砖长工一名,一直致力于挖坑(Bug)填坑(Debug),但技术却不见长进.也曾热情于新技术的学习,憧憬过成为技术大拿.从前端到后端,从bootstrap到javascript,从py ...

  2. 学习ABP ASP.NET Core with Angular 环境问题

    1. 前言 最近学习ABP架构 搭建ASP.NET Core with Angular遇到了些问题,折腾了一个礼拜最终在今天解决了,想想这个过程的痛苦就想利用博客记录下来.其实一直想写博客,但因为 时 ...

  3. ABP入门系列目录——学习Abp框架之实操演练

    ABP是"ASP.NET Boilerplate Project (ASP.NET样板项目)"的简称. ASP.NET Boilerplate是一个用最佳实践和流行技术开发现代WE ...

  4. 2019 年起如何开始学习 ABP 框架系列文章-开篇有益

    2019 年起如何开始学习 ABP 框架系列文章-开篇有益 [[TOC]] 本系列文章推荐阅读地址为:52ABP 开发文档 https://www.52abp.com/Wiki/52abp/lates ...

  5. 学习abp vnext框架到精简到我的Vop框架

    学习目标 框架特点 基于.NET 5平台开发 模块化系统 极少依赖 极易扩展 ....... 框架目的 学习.NET 5平台 学习abp vnext 上图大部分功能已经实现,多数是参考(copy)ab ...

  6. 关于OpenStack的学习路线及相关资源汇总

    首先我们想学习openstack,那么openstack是什么?能干什么?涉及的初衷是什么?由什么来组成?刚接触openstack,说openstack不是一个软件,而是由多个组件进行组合,这是一个更 ...

  7. python学习两月总结_汇总大牛们的思想_值得收藏

    下面是我汇总的我学习两个月python(version:3.3.2)的所有笔记 你可以访问:http://www.python.org获取更多信息 你也可以访问:http://www.cnblogs. ...

  8. django学习-15.ORM查询方法汇总

    1.前言 django的ORM框架提供的查询数据库表数据的方法很多,不同的方法返回的结果也不太一样,不同方法都有各自对应的使用场景. 主要常用的查询方法个数是13个,按照特点分为这4类: 方法返回值是 ...

  9. 一步一步学习ABP项目系列文章目录

    1.概述 基于DDD的.NET开发框架 - ABP初探 基于DDD的.NET开发框架 - ABP分层设计 基于DDD的.NET开发框架 - ABP模块设计 基于DDD的.NET开发框架 - ABP启动 ...

随机推荐

  1. OpenStack API部分高可用配置(二)

    一.安装与配置HAProxy 1.调整内核参数,允许绑定VIP: vim /etc/sysctl.conf [内容] net.ipv4.ip_nonlocal_bind=1 sysctl -p 2.安 ...

  2. Kafka 0.8 宕机问题排查步骤

    CPU 利用率高的排查方法 看看该机器的连接数是不是比其他机器多,监听的端口数:netstat -anlp | wc -l Kafka-0.8的停止和启动 启动: cd /usr/local/kafk ...

  3. hdu 527 Necklace

    http://acm.hdu.edu.cn/showproblem.php?pid=5727 阶乘 爆搜阴性宝石的排列,二分图最大匹配判断最多能使多少个阳性宝石不褪色 注: 1.O(n-1 !) 即可 ...

  4. 阿里云(一)云存储OSS的命令行osscmd的安装和使用

    一.安装Python 在Linux Shell里验证Python版本: $ python -V Python 2.7.10 二.安装OSScmd SDK osscmd是基于python 2.5.4(其 ...

  5. 用python处理文本,本地文件系统以及使用数据库的知识基础

    主要是想通过python之流的脚本语言来进行文件系统的遍历,处理文本以及使用简易数据库的操作. 本文基于陈皓的:<程序员技术练级攻略> 一.Python csv 对于电子表格和数据库导出文 ...

  6. [python]使用python实现Hadoop MapReduce程序:计算一组数据的均值和方差

    这是参照<机器学习实战>中第15章“大数据与MapReduce”的内容,因为作者写作时hadoop版本和现在的版本相差很大,所以在Hadoop上运行python写的MapReduce程序时 ...

  7. lemon spj无效编译器解决方法

    反正我是被坑了很久,心里增的敲难过呀! 我曾经无数次的想把它解决掉: 啊啊啊啊啊啊! 什么嘛!什么嘛! 这个空白的框框里到底要填什么嘛!!! 你已经是一个成熟的lemon了,就不能自动识别给个选项吗! ...

  8. xml json

    简单概括的话就是,xml本身是一种格式规范,是一种包含了数据以及数据说明的文本格式规范. 比如,我们要给对方传输一段数据,数据内容是“too young,too simple,sometimes na ...

  9. mybatis批量增加与删除——(十五)

    1.首先应该明白,mybatis增删改返回值是int型的影响行数的值 mapper接口 package cn.xm.mapper; import java.util.List; import cn.x ...

  10. 基于theano的多层感知机的实现

    1.引言 一个多层感知机(Multi-Layer Perceptron,MLP)可以看做是,在逻辑回归分类器的中间加了非线性转换的隐层,这种转换把数据映射到一个线性可分的空间.一个单隐层的MLP就可以 ...