Wed Jun 28 02:39:00 UTC 2023 inscode

上级 d17bf970
package com.lhstack; package com.lhstack;
import org.apache.catalina.connector.Connector; import java.lang.reflect.Method;
import org.apache.coyote.http11.Http11Nio2Protocol;
import org.apache.coyote.http11.Http11Processor;
import org.apache.tomcat.util.buf.MessageBytes;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.context.annotation.Bean;
import org.apache.coyote.Processor;
@SpringBootApplication @SpringBootApplication
public class TemplateApplication { public class TemplateApplication {
public static void main(String[] args) { public static void main(String[] args) {
try {
// Class classes = Class.forName("com.lhstack.Test");
// Class classes = Test.class;
Test test = new Test();
Class classes = test.getClass();
String methodName = "hello";
Class paratype[] = new Class[1];
paratype[0]=String.class;
Method method = classes.getDeclaredMethod(methodName, paratype);
method.invoke(classes.newInstance(), "testcj222m1");
System.err.println("++++++++++++++++++");
} catch (Exception e) {
// TODO: handle exception
}
SpringApplication.run(TemplateApplication.class, args); SpringApplication.run(TemplateApplication.class, args);
}
@Bean
public WebServerFactoryCustomizer<TomcatServletWebServerFactory> webServerFactoryCustomizer(){
return serverFactory -> {
Connector connector = new Connector(new Http11Nio2Protocol() {
@Override
protected Processor createProcessor() {
return new Http11Processor(this, this.getAdapter()) {
@Override
protected void parseHost(MessageBytes valueMB) {
MessageBytes messageBytes = MessageBytes.newInstance();
String hostname = valueMB.toString();
messageBytes.setString(hostname.replace("_", "-"));
messageBytes.toBytes();
super.parseHost(messageBytes);
}
};
}
});
connector.setPort(8080);
serverFactory.addAdditionalTomcatConnectors(connector);
};
} }
} }
package com.lhstack;
public class Test {
public void hello(String name){
// int i=1/0;
System.out.println("hello,"+name);
}
}
\ No newline at end of file
/root/springboot-template/src/main/java/com/lhstack/controller/CryptoController.java /root/springboot-template/src/main/java/com/lhstack/controller/CryptoController.java
/root/springboot-template/src/main/java/com/lhstack/Test.java
/root/springboot-template/src/main/java/com/lhstack/utils/Aes.java /root/springboot-template/src/main/java/com/lhstack/utils/Aes.java
/root/springboot-template/src/main/java/com/lhstack/config/WebMvcConfiguration.java /root/springboot-template/src/main/java/com/lhstack/config/WebMvcConfiguration.java
/root/springboot-template/src/main/java/com/lhstack/TemplateApplication.java /root/springboot-template/src/main/java/com/lhstack/TemplateApplication.java
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册