我正在为控制台应用程序开发 POC,在设置中使用 AddCommandLine 后,我正在努力从配置中检索命令行值。
工程项目
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
Run Code Online (Sandbox Code Playgroud)
节目类
public static class Program
{
public static async Task Main(string[] args)
{
Log.Logger = new LoggerConfiguration()
.Enrich.FromLogContext()
.WriteTo.Console()
.WriteTo.RollingFile("Logs//log.txt")
.CreateLogger();
await CreateHostBuilder(args)
.Build()
.RunAsync();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.UseSerilog()
.ConfigureAppConfiguration((hostingContext, config) =>
{
config.AddJsonFile("settings.json", true, true);
config.AddCommandLine(args);
})
.ConfigureServices((hostcontext, services) =>
{
services.AddHostedService<ConsoleApp>();
});
}
Run Code Online (Sandbox Code Playgroud)
控制台应用程序类
public class ConsoleApp : IHostedService
{
private readonly IConfiguration config;
private readonly ILogger<ConsoleApp> log;
public ConsoleApp(IConfiguration configuration, ILogger<ConsoleApp> logger)
{ …Run Code Online (Sandbox Code Playgroud) 我已经建立了一个项目来使用 Glassfish 4 和一个链接回 MySql 数据库的资源,我正在使用 Eclipse Keplar。我已经设置了具有相关详细信息的连接池,并且从 glassfish 管理页面 ping 成功。我有一个设置了 JPA 的 EJB 项目来访问资源,但是当在浏览器或 Eclipse 中尝试访问时,我收到“未选择数据库”错误。
在四处搜索后,我发现池的 Url 参数存在问题,将该参数重命名为 URL 可能会解决问题。我发现的帖子还建议我输入连接字符串,因为他怀疑正在进行不同的调用,并且字符串在 Glassfish 之外没有正确构建。我做了这些事情,但即使我在连接字符串中输入了密码,我还是收到了错误“无密码凭据”。
有没有其他人遇到过这个问题,并对问题是什么以及我如何解决有任何建议?
在迁移到我的 Linux 机器上工作时,我遇到了 Nuget 的问题。我们的项目是 .net core 3.1,每个项目都有自己的 nuget.config 文件,其中有四个包源。第一个是显而易见的,但其余的都是针对公司的。
\n每当我构建时,我都会收到一条错误消息,指出我未获得授权:
\n/usr/share/dotnet/sdk/3.1.301/NuGet.targets(128,5):错误:无法加载源https://aldinternational.pkgs.visualstudio.com/_packaging/PLASMA/nuget/的服务索引v3/index.json。[/home/lg/Documents/ALD/repo/CampaignIngestion.OmegaConnector/OmegaConnector.Functions/OmegaConnector.Functions.csproj]\n/usr/share/dotnet/sdk/3.1.301/NuGet.targets(128,5):错误:响应状态代码不表示成功:401(未经授权)。[/home/lg/Documents/ALD/repo/CampaignIngestion.OmegaConnector/OmegaConnector.Functions/OmegaConnector.Functions.csproj]\n0 警告\n1 错误
\n但当我将其放入浏览器中时,我可以获得 json 输出。我跑了:
\nmozroots --import --sync --url https://hg.mozilla.org/mozilla-central/raw-file/tip/security\xe2\x80\x8c\xe2\x80\x8b/nss/lib/ckfw/内置\xe2\x80\x8c\xe2\x80\x8bns/certdata.txt
\n因为我发现它的线程似乎有类似的问题,但对我来说没有运气。
\ndotnet --info output\n\n.NET Core SDK (reflecting any global.json):\n Version: 3.1.301\n Commit: 7feb845744\n\nRuntime Environment:\n OS Name: ubuntu\n OS Version: 18.04\n OS Platform: Linux\n RID: ubuntu.18.04-x64\n Base Path: /usr/share/dotnet/sdk/3.1.301/\n\nHost (useful for support):\n Version: 3.1.5\n Commit: 65cd789777\n\n.NET Core SDKs installed:\n 2.1.302 [/usr/share/dotnet/sdk]\n 2.2.300 [/usr/share/dotnet/sdk]\n 3.1.301 [/usr/share/dotnet/sdk]\n\n.NET Core runtimes installed:\n Microsoft.AspNetCore.All 2.1.2 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All]\n …Run Code Online (Sandbox Code Playgroud)