Skip to content

Commit

Permalink
V3.0 develop enhancement configuration file and fix deploy problem (#…
Browse files Browse the repository at this point in the history
…13009)

* Sort and enhance nacos application.properties.

* fix deploy and compile problem.
  • Loading branch information
KomachiSion authored Jan 2, 2025
1 parent cd7de01 commit f54edab
Show file tree
Hide file tree
Showing 16 changed files with 406 additions and 989 deletions.
37 changes: 37 additions & 0 deletions bootstrap/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,41 @@
<artifactId>nacos-server</artifactId>
</dependency>
</dependencies>

<profiles>
<profile>
<id>release-nacos</id>
<build>
<finalName>nacos-server</finalName>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>com.alibaba.nacos.bootstrap.NacosBootstrap</mainClass>
<layout>ZIP</layout>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.io.ClassPathResource;
import org.springframework.jmx.support.MBeanRegistrationSupport;
import org.springframework.jmx.export.MBeanExporter;
import org.springframework.jmx.support.RegistrationPolicy;

/**
Expand All @@ -40,11 +40,11 @@
@SpringBootApplication
public class NacosBootstrap {

private static final String SPRING_JXM_ENABLED = "spring.jmx.enabled";

public static void main(String[] args) {
ConfigurableApplicationContext coreContext = startCoreContext(args);
coreContext.getBean(MBeanRegistrationSupport.class).setRegistrationPolicy(RegistrationPolicy.IGNORE_EXISTING);
String type = coreContext.getEnvironment()
.getProperty(Constants.NACOS_DEPLOYMENT_TYPE, Constants.NACOS_DEPLOYMENT_TYPE_MERGED);
String type = prepareCoreContext(coreContext);
if (Constants.NACOS_DEPLOYMENT_TYPE_MERGED.equals(type)) {
startWithConsole(args, coreContext);
} else if (Constants.NACOS_DEPLOYMENT_TYPE_SERVER.equals(type)) {
Expand All @@ -54,6 +54,15 @@ public static void main(String[] args) {
}
}

private static String prepareCoreContext(ConfigurableApplicationContext coreContext) {
if (coreContext.getEnvironment().getProperty(SPRING_JXM_ENABLED, Boolean.class, false)) {
// Avoid duplicate registration MBean to exporter.
coreContext.getBean(MBeanExporter.class).setRegistrationPolicy(RegistrationPolicy.IGNORE_EXISTING);
}
return coreContext.getEnvironment()
.getProperty(Constants.NACOS_DEPLOYMENT_TYPE, Constants.NACOS_DEPLOYMENT_TYPE_MERGED);
}

private static void startWithoutConsole(String[] args, ConfigurableApplicationContext coreContext) {
ConfigurableApplicationContext webContext = startServerWebContext(args, coreContext);
}
Expand Down
Loading

0 comments on commit f54edab

Please sign in to comment.