Skip to content

Commit

Permalink
[ISSUE alibaba#3379]Unable to use Nacos configuration information cor…
Browse files Browse the repository at this point in the history
…rectly when configuring the nacos endpoint alibaba#3379
  • Loading branch information
huhongjie2014 committed Jul 12, 2023
1 parent 6e02b51 commit 0f44491
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,18 @@ public class NacosDataSourceFactoryBean implements FactoryBean<NacosDataSource>
@Override
public NacosDataSource getObject() throws Exception {
Properties properties = new Properties();
if (!StringUtils.isEmpty(this.serverAddr)) {
properties.setProperty(PropertyKeyConst.SERVER_ADDR, this.serverAddr);
if (!StringUtils.isEmpty(this.endpoint)) {
int index = this.endpoint.indexOf(":");
if (index < 0) {
properties.setProperty(PropertyKeyConst.ENDPOINT, this.endpoint);
}
else {
properties.setProperty(PropertyKeyConst.ENDPOINT, this.endpoint.substring(0, index));
properties.setProperty(PropertyKeyConst.ENDPOINT_PORT, this.endpoint.substring(index + 1));
}
}
else {
properties.setProperty(PropertyKeyConst.ENDPOINT, this.endpoint);
properties.setProperty(PropertyKeyConst.SERVER_ADDR, this.serverAddr);
}

if (!StringUtils.isEmpty(this.contextPath)) {
Expand Down

0 comments on commit 0f44491

Please sign in to comment.