我创建了一个SpringBoot应用程序。 我想在我的本地服务器(Weblogic 12c)上部署它。 当我尝试部署战争时,我收到此错误消息:
java.lang.IllegalArgumentException
:源类型类my.company.MySpringBootApplication无效
这是我的罪恶类:
package my.company;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
@SpringBootApplication
public class MySpringBootApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(MySpringBootApplication.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(this);
}
}
我该如何解决这个问题?
提前致谢;)
答案 0 :(得分:0)
这只是替换这一行的问题:
package my.company;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.WebApplicationInitializer;
@ComponentScan
@EnableAutoConfiguration
public class MySpringBootApplication extends SpringBootServletInitializer implements WebApplicationInitializer {
@Value("${flag.status}")
private String flagStatus;
public static void main(String[] args) {
SpringApplication.run(MySpringBootApplication.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(applicationClass);
}
private static Class<MySpringBootApplication > applicationClass = MySpringBootApplication .class;
}