学习ABP遇到的问题汇总
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改为(这个可以不管)
<dependentAssembly>
<assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.2.1.0" newVersion="1.2.1.0" />
</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方法加上扩展配置
using Abp.Configuration.Startup;
using Abp.Localization.Dictionaries;
using Abp.Localization.Dictionaries.Xml;
using Abp.Localization.Sources;
using Abp.Reflection.Extensions; namespace Ousutec.Duty.Localization
{
public static class DutyLocalizationConfigurer
{
public static void Configure(ILocalizationConfiguration localizationConfiguration)
{
localizationConfiguration.Sources.Add(
new DictionaryBasedLocalizationSource(DutyConsts.LocalizationSourceName,
new XmlEmbeddedFileLocalizationDictionaryProvider(
typeof(DutyLocalizationConfigurer).GetAssembly(),
"Ousutec.Duty.Localization.SourceFiles"
)
)
); localizationConfiguration.Sources.Extensions.Add(
new LocalizationSourceExtensionInfo("AbpWeb",
new XmlEmbeddedFileLocalizationDictionaryProvider(
typeof(DutyLocalizationConfigurer).GetAssembly(),
"Ousutec.Duty.Localization.AbpWebExtensions"
)
)
);
}
}
}
DutyLocalizationConfigurer
将Abp.Web.Common源码的AbpWeb-zh-Hans.xml复制到Ousutec.Duty.Core项目中。并嵌入资源
11,关于自动注册依赖
约定名称必须一直,例如
using System;
using System.Collections.Generic;
using System.Text;
using Castle.Core.Logging;
using Ousutec.Duty.Common;
using Newtonsoft.Json; using Abp.Dependency;
using Ousutec.Duty.DutyCmds;
using Abp.AutoMapper; namespace Ousutec.Duty.RabbitMqListeners
{
public class DutyCmdListener : IDutyCmdListener, ITransientDependency
{
private readonly ILogger _logger;
private readonly IDutyCmdAppService _dutyCmdAppService;
public DutyCmdListener(ILogger logger, IDutyCmdAppService dutyCmdAppService)
{
_logger = logger;
_dutyCmdAppService = dutyCmdAppService;
} public void ProcessMsg(DutyCmdMessage msg)
{
_logger.Info(JsonConvert.SerializeObject(msg));
_dutyCmdAppService.Add(msg.DutyCmdDtos.MapTo<IEnumerable<Addinput>>());
}
}
}
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);
// Swagger - Enable this line and the related lines in Configure method to enable swagger UI
services.AddSwaggerGen(options =>
{
options.SwaggerDoc("v1", new Info { Title = "Duty API", Version = "v1" });
options.DocInclusionPredicate((docName, description) => true); options.CustomSchemaIds(t => t.FullName);
// Define the BearerAuth scheme that's in use
options.AddSecurityDefinition("bearerAuth", new ApiKeyScheme()
{
Description = "JWT Authorization header using the Bearer scheme. Example: \"Authorization: Bearer {token}\"",
Name = "Authorization",
In = "header",
Type = "apiKey"
});
// Assign scope requirements to operations based on AuthorizeAttribute
options.OperationFilter<SecurityRequirementsOperationFilter>();
});
Startup
13,接口返回参数命名,忽略abp框架设置的命名规则
using System;
using System.Linq;
using System.Reflection;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc.Cors.Internal;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Castle.Facilities.Logging;
using Swashbuckle.AspNetCore.Swagger;
using Abp.AspNetCore;
using Abp.Castle.Logging.Log4Net;
using Abp.Extensions;
using Ousu.DataCollection.Attendance.Authentication.JwtBearer;
using Ousu.DataCollection.Attendance.Configuration;
using Ousu.DataCollection.Attendance.Identity;
using Ousu.DataCollection.Attendance.Common;
using Abp.AspNetCore.SignalR.Hubs;
using Ousu.DataCollection.Attendance.AttendanceCmds;
using Abp.Dependency;
using Castle.Windsor.MsDependencyInjection;
using Aliyun.OSS;
using Castle.Core.Logging;
using Abp.Json;
using Newtonsoft.Json.Serialization;
using Abp; namespace Ousu.DataCollection.Attendance.Web.Host.Startup
{
public class Startup
{
private const string _defaultCorsPolicyName = "localhost"; private readonly IConfigurationRoot _appConfiguration; public Startup(IHostingEnvironment env)
{
_appConfiguration = env.GetAppConfiguration();
} public IServiceProvider ConfigureServices(IServiceCollection services)
{ // MVC
services.AddMvc(
options =>
{
options.Filters.Add(new CorsAuthorizationFilterFactory(_defaultCorsPolicyName));
}
); IdentityRegistrar.Register(services);
AuthConfigurer.Configure(services, _appConfiguration); services.AddSignalR(); // Configure CORS for angular2 UI
services.AddCors(
options => options.AddPolicy(
_defaultCorsPolicyName,
builder => builder
.WithOrigins(
// App:CorsOrigins in appsettings.json can contain more than one address separated by comma.
_appConfiguration["App:CorsOrigins"]
.Split(",", StringSplitOptions.RemoveEmptyEntries)
.Select(o => o.RemovePostFix("/"))
.ToArray()
)
.AllowAnyHeader()
.AllowAnyMethod()
.AllowCredentials()
)
); // Swagger - Enable this line and the related lines in Configure method to enable swagger UI
services.AddSwaggerGen(options =>
{
options.SwaggerDoc("v1", new Info { Title = "Attendance API", Version = "v1" });
options.DocInclusionPredicate((docName, description) => true); options.CustomSchemaIds(t => t.FullName);
// Define the BearerAuth scheme that's in use
options.AddSecurityDefinition("bearerAuth", new ApiKeyScheme()
{
Description = "JWT Authorization header using the Bearer scheme. Example: \"Authorization: Bearer {token}\"",
Name = "Authorization",
In = "header",
Type = "apiKey"
});
// Assign scope requirements to operations based on AuthorizeAttribute
options.OperationFilter<SecurityRequirementsOperationFilter>();
}); //去除abp框架自带的命名规则
services.PostConfigure<MvcJsonOptions>(options =>
{
options.SerializerSettings.ContractResolver = new AbpContractResolver();
}); // Configure Abp and Dependency Injection
return services.AddAbp<AttendanceWebHostModule>(
// Configure Log4Net logging
options =>
{
options.IocManager.IocContainer.AddFacility<LoggingFacility>(f => f.UseAbpLog4Net().WithConfig("log4net.config"));
}
);
} public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
app.UseAbp(options => { options.UseAbpRequestLocalization = false;}); // Initializes ABP framework. app.UseCors(_defaultCorsPolicyName); // Enable CORS! app.UseStaticFiles(); app.UseAuthentication(); app.UseAbpRequestLocalization(); app.UseSignalR(routes =>
{
routes.MapHub<AbpCommonHub>("/signalr");
}); app.UseMvc(routes =>
{
routes.MapRoute(
name: "defaultWithArea",
template: "{area}/{controller=Home}/{action=Index}/{id?}"); routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
}); // Enable middleware to serve generated Swagger as a JSON endpoint
app.UseSwagger();
// Enable middleware to serve swagger-ui assets (HTML, JS, CSS etc.)
app.UseSwaggerUI(options =>
{
options.SwaggerEndpoint(_appConfiguration["App:ServerRootAddress"] + "/swagger/v1/swagger.json", "Attendance API V1");
options.IndexStream = () => Assembly.GetExecutingAssembly()
.GetManifestResourceStream("Ousu.DataCollection.Attendance.Web.Host.wwwroot.swagger.ui.index.html");
}); // URL: /swagger
}
}
}
去除abp框架自带的命名规则
14,不使用abp框架自带的返回格式
在类或者方法上加上[DontWrapResult]特性
学习ABP遇到的问题汇总的更多相关文章
- ABP入门系列(1)——学习Abp框架之实操演练
作为.Net工地搬砖长工一名,一直致力于挖坑(Bug)填坑(Debug),但技术却不见长进.也曾热情于新技术的学习,憧憬过成为技术大拿.从前端到后端,从bootstrap到javascript,从py ...
- 学习ABP ASP.NET Core with Angular 环境问题
1. 前言 最近学习ABP架构 搭建ASP.NET Core with Angular遇到了些问题,折腾了一个礼拜最终在今天解决了,想想这个过程的痛苦就想利用博客记录下来.其实一直想写博客,但因为 时 ...
- ABP入门系列目录——学习Abp框架之实操演练
ABP是"ASP.NET Boilerplate Project (ASP.NET样板项目)"的简称. ASP.NET Boilerplate是一个用最佳实践和流行技术开发现代WE ...
- 2019 年起如何开始学习 ABP 框架系列文章-开篇有益
2019 年起如何开始学习 ABP 框架系列文章-开篇有益 [[TOC]] 本系列文章推荐阅读地址为:52ABP 开发文档 https://www.52abp.com/Wiki/52abp/lates ...
- 学习abp vnext框架到精简到我的Vop框架
学习目标 框架特点 基于.NET 5平台开发 模块化系统 极少依赖 极易扩展 ....... 框架目的 学习.NET 5平台 学习abp vnext 上图大部分功能已经实现,多数是参考(copy)ab ...
- 关于OpenStack的学习路线及相关资源汇总
首先我们想学习openstack,那么openstack是什么?能干什么?涉及的初衷是什么?由什么来组成?刚接触openstack,说openstack不是一个软件,而是由多个组件进行组合,这是一个更 ...
- python学习两月总结_汇总大牛们的思想_值得收藏
下面是我汇总的我学习两个月python(version:3.3.2)的所有笔记 你可以访问:http://www.python.org获取更多信息 你也可以访问:http://www.cnblogs. ...
- django学习-15.ORM查询方法汇总
1.前言 django的ORM框架提供的查询数据库表数据的方法很多,不同的方法返回的结果也不太一样,不同方法都有各自对应的使用场景. 主要常用的查询方法个数是13个,按照特点分为这4类: 方法返回值是 ...
- 一步一步学习ABP项目系列文章目录
1.概述 基于DDD的.NET开发框架 - ABP初探 基于DDD的.NET开发框架 - ABP分层设计 基于DDD的.NET开发框架 - ABP模块设计 基于DDD的.NET开发框架 - ABP启动 ...
随机推荐
- Go 语言编程规范
1. gofmt 命令 大部分的格式问题可以通过 gofmt 来解决,gofmt 自动格式化代码,保证所有的 go 代码与官方推荐的格式保持一致,所有格式有关问题,都以gofmt的结果为准.所以,建议 ...
- Java基础-SSM之mybatis快速入门篇
Java基础-SSM之mybatis快速入门篇 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 其实你可能会问什么是SSM,简单的说就是spring mvc + Spring + m ...
- 鸟哥的Linux私房菜——第十六章:学习Shell Scripts
视频链接:http://www.bilibili.com/video/av10565321/ 1. 什么是 Shell Script (shell写的脚本)1.1 干嘛学习 shell s ...
- 转:Xcode打印堆栈信息
2# 分享于 14-11-26 19:15:36 Chrome 39.0.2171.71 Mac OS X 10.10.1 如果只是看调用栈的话,可以使用 lldb 的功能.在你的代码里面打上一个 ...
- 阿里云ECS使用cloudfs4oss挂载OSS
cloudfs4oss可以帮我们将OSS直接挂载到ECS上,就像一个目录一样方便访问.使用方法: 1.安装配置环境: yum install libcurl libcurl-devel openssl ...
- HDU 2988 Dark roads (裸的最小生成树)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2988 解题报告:一个裸的最小生成树,没看题,只知道结果是用所有道路的总长度减去最小生成树的长度和. # ...
- nginx配置thinkphp5
[root@z_centos nginx]# /usr/local/nginx/sbin/nginx -hnginx version: nginx/1.13.9thinkphp 5.0.18 [roo ...
- MySQL灾备恢复在线主从复制变成主主复制及多源复制【转】
生产主主复制(A<--->B),和灾备主从复制(B--->C).当生产出现问题时,数据写入切换到灾备数据库,待生产恢复后,将灾备回写到生产.步骤如下: 1.灾备与生产其中一台建立主主 ...
- shell函数中eof报错(warning: here-document at line 9 delimited by end-of-file (wanted `EOF'))
在shell编写函数时,函数中有eof和EOF,如果是在sublime编写按照格式tab缩进会有以下报错 解决办法: 取消函数中的tab缩进,在运行即可
- sh-copy-id命令报错:-bash: ssh-copy-id: command not found
参考网址:http://www.bubuko.com/infodetail-1662159.html yum -y install openssh-clients