我创建了一个Micronaut应用程序,该应用程序可以通过jdbctemplate访问多个数据源。我这样配置了jdbctemplates:
Public Function getOutlookAppointments() As String
Dim oOutlook As Object
Dim oNS As Object
Dim oAppointments As Object
Dim oFilterAppointments As Object
Dim oAppointmentItem As Object
Dim bOutlookOpened As Boolean
' Dim rslt As String
Dim sfilter As String
Dim startDate As Date
Dim displayText As String
Dim start As Date
Const olFolderCalendar = 9
On Error Resume Next
Set oOutlook = GetObject(, "Outlook.Application") 'Bind to existing instance of Outlook
If Err.Number <> 0 Then 'Could not get instance of Outlook, so create a new one
Err.Clear
Set oOutlook = CreateObject("Outlook.Application")
bOutlookOpened = False 'Outlook was not already running, we had to start it
Else
bOutlookOpened = True 'Outlook was already running
End If
On Error GoTo Error_Handler
DoEvents
Set oNS = oOutlook.GetNamespace("MAPI")
Set oAppointments = oNS.GetDefaultFolder(olFolderCalendar)
startDate = cmDates.srtDate.value
'Apply a filter so we don't waste our time going through old stuff if we don't need to.
sfilter = "[Start] = '" & startDate & "' "
Set oFilterAppointments = oAppointments.Items.Restrict(sfilter)
For Each oAppointmentItem In oFilterAppointments
getOutlookAppointments = getOutlookAppointments & oFilterAppointments.Count & " appointment(s) found" & vbCrLf & vbCrLf & oAppointmentItem.Subject & vbCrLf & oAppointmentItem.start & vbCrLf & oAppointmentItem.End & vbCrLf & vbCrLf
'displayText = displayText & oAppointmentItem.Subject
Next
MsgBox prompt:=getOutlookAppointments, _
Title:="Appointments for"
If bOutlookOpened = False Then 'Since we started Outlook, we should close it now that we're done
oOutlook.Quit 'There seems to be a delay in this action taking place, but does eventually take place
End If
Error_Handler_Exit:
On Error Resume Next
Set oAppointmentItem = Nothing
Set oFilterAppointments = Nothing
Set oAppointments = Nothing
Set oNS = Nothing
Set oOutlook = Nothing
Exit Function
Error_Handler:
MsgBox "The following error has occured" & vbCrLf & vbCrLf & _
"Error Number: " & Err.Number & vbCrLf & _
"Error Source: GetFutureOutlookEvents" & vbCrLf & _
"Error Description: " & Err.Description _
, vbOKOnly + vbCritical, "An Error has Occured!"
Resume Error_Handler_Exit
outlookDates = False
End Function
这使用@Factory
@Requires(beans = DatasourceFactory.class)
public class JdbcTemplateFactory {
@Context
@EachBean(DataSource.class)
JdbcTemplate jdbcTemplate(DataSource dataSource) {
return new JdbcTemplate(dataSource);
}
}
消耗了我的配置yml:
io.micronaut.configuration.jdbc.tomcat.DatasourceFactory
问题是我想以某种方式解密来自配置的密码。我的第一个尝试是“替换”工厂使用的datasources:
datasource111111:
url: url
username: username
password: password
driverClassName: org.h2.Driver
datasource222222:
url: url
username: username
password: password
driverClassName: org.h2.Driver
bean,但是没有运气,它给了我一个没有道理的错误(io.micronaut.context.exceptions.DependencyInjectionException)。
这是我的替换尝试:
DatasourceConfiguration
知道我在做什么错吗?谢谢!
答案: 必须听建议的bean创建
@Replaces(DatasourceConfiguration.class)
@EachProperty(value = BasicJdbcConfiguration.PREFIX, primary = "default")
public class EncryptedDatasourceConfiguration extends DatasourceConfiguration {
public EncryptedDatasourceConfiguration(String name) {
super(name);
}
@Override
public String getPassword() {
return "encrypted password";
}
}
答案 0 :(得分:0)
您最好创建一个<div id="new-section-container" v-show="showSection" class="col-md-8">
<h6>Section Name</h6>
<input type="text" id="sectionName" class="w-100 form-control" name="Name" placeholder="Name">
</div>
来读取密码,解密并在配置中重新设置密码