
package com.logicbig.example;
import org.springframework.boot.SpringApplication;
import java.net.MalformedURLException;
public class CommandLineAppPropsSwitchExample {
public static void main(String[] args) throws MalformedURLException {
SpringApplication app = new SpringApplication(CustomBannerExample.class);
app.setLogStartupInfo(false);
//rename my-application.properties to application.properties
//or use a command line switch.. here we just overriding args
String[] myArgs = {"--spring.config.name=my-application"};
app.run(myArgs);
}
}
Output
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:4.1.2:run (default-cli) on project boot-startup-customizing: Execution default-cli of goal org.springframework.boot:spring-boot-maven-plugin:4.1.2:run failed: Unable to find a single main class from the following candidates [com.logicbig.example.TurnOffLogsExample, com.logicbig.example.SetDefaultPropertiesExample, com.logicbig.example.CustomBannerExample, com.logicbig.example.CommandLinePropSwitchExample, com.logicbig.example.CommandLineAppPropsSwitchExample, com.logicbig.example.BannerOffExample] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
JDK 25Original PostCustomizing spring, setting command line switch for banner location.

package com.logicbig.example;
import org.springframework.boot.SpringApplication;
import java.net.MalformedURLException;
public class CommandLinePropSwitchExample {
public static void main(String[] args) throws MalformedURLException {
SpringApplication app = new SpringApplication(
CommandLinePropSwitchExample.class);
app.setLogStartupInfo(false);
//rename resources/my-banner.txt to banner.txt
//here we are just using command line arg
String[] strings = {"--banner.location=my-banner.txt"};
app.run(strings);
}
}
Output
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:4.1.2:run (default-cli) on project boot-startup-customizing: Execution default-cli of goal org.springframework.boot:spring-boot-maven-plugin:4.1.2:run failed: Unable to find a single main class from the following candidates [com.logicbig.example.TurnOffLogsExample, com.logicbig.example.SetDefaultPropertiesExample, com.logicbig.example.CustomBannerExample, com.logicbig.example.CommandLinePropSwitchExample, com.logicbig.example.CommandLineAppPropsSwitchExample, com.logicbig.example.BannerOffExample] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
JDK 25Original Post

package com.logicbig.example;
import org.springframework.boot.SpringApplication;
import java.net.MalformedURLException;
import java.util.Properties;
public class SetDefaultPropertiesExample {
public static void main(String[] args) throws MalformedURLException {
SpringApplication app = new SpringApplication(CustomBannerExample.class);
Properties p = new Properties();
p.setProperty("spring.banner.location", "my-banner.txt");
p.setProperty("spring.main.log-startup-info", "false");
app.setDefaultProperties(p);
app.run(args);
}
}
Output
---------------------
Test Banner
---------------------
Original Post

package com.logicbig.example;
import org.springframework.boot.SpringApplication;
import java.net.MalformedURLException;
public class TurnOffLogsExample {
public static void main(String[] args) throws MalformedURLException {
SpringApplication app = new SpringApplication(TurnOffLogsExample.class);
app.setLogStartupInfo(false);
app.run(args);
}
}
Output
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v4.2.0)
Original Post