Spring Boot Auto配置spring.factories

时间:2018-03-27 18:31:26

标签: spring spring-cloud

我按照说明here提供自定义RestTemplate。

  • 我已经创建了spring.factories文件并验证它是否在 META-INF目录或JAR。

  • 我按照描述创建了这个类。

  • 我在

    中添加了一些日志语句

    app.UseOpenIdConnectAuthentication( new OpenIdConnectAuthenticationOptions { ClientId = clientId, Authority = authority, PostLogoutRedirectUri = postLogoutRedirectUri, RedirectUri = postLogoutRedirectUri, Notifications = new OpenIdConnectAuthenticationNotifications { AuthenticationFailed = context => { context.HandleResponse(); context.Response.Redirect("/Error?message=" + context.Exception.Message); return Task.FromResult(0); } }, TokenValidationParameters = new System.IdentityModel.Tokens.TokenValidationParameters { ValidateIssuer = false, RoleClaimType = "roles", } }); 并且在我运行应用程序后它们不会出现。

    似乎正在忽略spring.factories文件。

如何让应用程序加载spring.factories文件?

1 个答案:

答案 0 :(得分:1)

尝试添加配置:

import random
import csv
fname = ['Red','Jose','Mikasa','Sakura','Naruto','Momoka','Zero','Ryu','Ken','Geralt','Greg','Mika','Momo','Xenovia','John','Gary','Lance','Eren','Duke','Claire']
lname = ['Akerman','Haruno','Johnson','Rivia','Valentine','Redfield','Kennedy','Juarez','Jameson','Williams','Miller','Davis','Thompson','Garcia','Remington','Hayabusa','Strife','Armstrong','Kojima','Chambers']
grade = ['A','B','C','D','F']

def ranint():
    value = random.randint(60, 100)
    #print(value)
    return value

def ranname():
    first = random.choice(fname)
    last = random.choice(lname)
    #print(first,last)
    fname.remove(first)
    lname.remove(last)
    return "; ".join([first, last])

def rangrade():
    fgrade = random.choice(grade)
    #print(fgrade)
    return fgrade

with open('grades.csv','w',newline='') as fp:
    a = csv.writer(fp,delimiter=',')
    data = [['Name', 'Assignment1', 'Assignment2', 'Assignment3', 'Assignment4', 'Quiz1', 'Quiz2', 'Quiz3', 'Quiz4', 'Total_Grade'],
        [ranname(), ranint(), ranint(), ranint(), ranint(), ranint(), ranint(), ranint(), ranint(), rangrade()],
        [ranname(), ranint(), ranint(), ranint(), ranint(), ranint(), ranint(), ranint(), ranint(), rangrade()],
        [ranname(), ranint(), ranint(), ranint(), ranint(), ranint(), ranint(), ranint(), ranint(), rangrade()]]
    a.writerows(data)

并在下次提供你的spring-cloud版本