com.ones.ali.nlp.autoconfigure.OsNlpAutoConfiguration Maven / Gradle / Ivy
/*
*
* * Copyright (c) 2021 os-parent Authors. All Rights Reserved.
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/
package com.ones.ali.nlp.autoconfigure;
import com.ones.ali.nlp.util.OsNlpUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
/**
* os-ali-nlp配置
* @author Clark
* @version 2022-05-26
*/
@AutoConfiguration
@EnableConfigurationProperties(OsNlpProperties.class)
@ConditionalOnProperty(value = {"os.nlp.accessKeyId", "os.nlp.accessKeySecret"})
public class OsNlpAutoConfiguration {
@Autowired
private OsNlpProperties properties;
@Bean
@ConditionalOnMissingBean
public OsNlpUtils osNlpUtils() {
OsNlpUtils osNlpUtils = null;
try {
osNlpUtils = new OsNlpUtils(this.properties.getAccessKeyId(), this.properties.getAccessKeySecret());
} catch (Exception e) {
e.printStackTrace();
}
return osNlpUtils;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy