我需要在我的公司中运行一个已经存在的项目。但是,当我尝试通过Web浏览器访问时,此项目显示RAW JSON而不是HTML,如下所示。
这是我的应用文件
@SpringBootApplication
@EnableAutoConfiguration
@EnableSwagger2
@EnableScheduling
@EnableTransactionManagement(proxyTargetClass = true)
@ComponentScan({"io.convergencia", "integrador"})
@EnableJpaRepositories(basePackages = {"io.convergencia.erp.painel.repository", io.convergencia.erp.painel.repository.common"}, repositoryFactoryBeanClass = BaseRepositoryFactoryBean.class)
public class InterfaceErpWebappOnlyPainel {
public static void main(String[] args) {
SpringApplication.run(InterfaceErpWebappOnlyPainel.class, args);
}
@Bean
@ConfigurationProperties("spring.datasource")
public DataSource dataSource() {
return DataSourceBuilder.create().build();
}
@Bean
@ConfigurationProperties(prefix = "custom")
public Custom custom() {
return new Custom();
}
// OAUTH AND SECURITY CONFIGS
@Configuration
@Order(1) // HIGHEST -> LOWEST
public static class OAuthSecurityConfigurerAdapter extends WebSecurityConfigurerAdapter {
private ZeroLeggedOAuthProviderProcessingFilter zeroLeggedOAuthProviderProcessingFilter;
@Autowired
OAuthConsumerDetailsService oauthConsumerDetailsService;
@Autowired
OAuthAuthenticationHandler oauthAuthenticationHandler;
@Autowired
OAuthProcessingFilterEntryPoint oauthProcessingFilterEntryPoint;
@Autowired
OAuthProviderTokenServices oauthProviderTokenServices;
@PostConstruct
public void init() {
zeroLeggedOAuthProviderProcessingFilter = new ZeroLeggedOAuthProviderProcessingFilter(
oauthConsumerDetailsService, new InMemoryNonceServices(), oauthProcessingFilterEntryPoint,
oauthAuthenticationHandler, oauthProviderTokenServices);
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http.antMatcher("/api/**")
.addFilterBefore(zeroLeggedOAuthProviderProcessingFilter,
UsernamePasswordAuthenticationFilter.class)
.authorizeRequests().anyRequest().hasRole("OAUTH");
http.csrf().disable();
}
}
@Order(100) // LOWEST -> HIGHEST
@Configuration
public static class NoAuthConfigurationAdapter extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.antMatcher("/**").authorizeRequests().anyRequest().permitAll();
http.csrf();
}
}
@Bean(name = "oauthAuthenticationEntryPoint")
public OAuthProcessingFilterEntryPoint oauthAuthenticationEntryPoint() {
return new OAuthProcessingFilterEntryPointImpl();
}
@Bean(name = "oauthProviderTokenServices")
public OAuthProviderTokenServices oauthProviderTokenServices() {
return new InMemoryProviderTokenServices();
}
@Bean(name = "threadPool")
public ThreadPoolTaskExecutor threadPoolTaskExecutor(@Value("${app.threads.corePoolSize}") String corePoolSize,
@Value("${app.threads.maxMaxPoolSize}") String maxMaxPoolSize) {
ThreadPoolTaskExecutor threadPool = new ThreadPoolTaskExecutor();
threadPool.setCorePoolSize(Integer.parseInt(corePoolSize));
threadPool.setMaxPoolSize(Integer.parseInt(maxMaxPoolSize));
threadPool.setWaitForTasksToCompleteOnShutdown(false);
return threadPool;
}
public static class ZeroLeggedOAuthProviderProcessingFilter extends ProtectedResourceProcessingFilter {
ZeroLeggedOAuthProviderProcessingFilter(OAuthConsumerDetailsService oAuthConsumerDetailsService,
OAuthNonceServices oAuthNonceServices, OAuthProcessingFilterEntryPoint oAuthProcessingFilterEntryPoint,
OAuthAuthenticationHandler oAuthAuthenticationHandler,
OAuthProviderTokenServices oAuthProviderTokenServices) {
super();
System.out.println("CONSTRUCT Zero Legged OAuth provider");
setIgnoreMissingCredentials(false);
setAuthenticationEntryPoint(oAuthProcessingFilterEntryPoint);
setAuthHandler(oAuthAuthenticationHandler);
setConsumerDetailsService(oAuthConsumerDetailsService);
setNonceServices(oAuthNonceServices);
setTokenServices(oAuthProviderTokenServices);
}
}
public static class OAuthProcessingFilterEntryPointImpl extends OAuthProcessingFilterEntryPoint {
@Override
public void commence(HttpServletRequest arg0, HttpServletResponse arg1, AuthenticationException arg2)
throws IOException, ServletException {
super.commence(arg0, arg1, arg2);
}
}
// JSON HIBERNATE CONFIGS
@Configuration
public static class MvcConf extends WebMvcConfigurerAdapter {
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
converters.add(new MappingJackson2HttpMessageConverter(new HibernateAwareObjectMapper()));
super.configureMessageConverters(converters);
}
}
public static class HibernateAwareObjectMapper extends ObjectMapper {
public HibernateAwareObjectMapper() {
Hibernate5Module module = new Hibernate5Module();
module.enable(Hibernate5Module.Feature.FORCE_LAZY_LOADING);
registerModule(module);
}
}
}
这是我的pom文件 http://maven.apache.org/xsd/maven-4.0.0.xsd“> 4.0.0 interfaceerp-webapp-painel 集成商-erp-painel 0.0.1-快照 集成商-erp-painel org.springframework.boot 弹簧启动启动器父母 1.4.7。发布
<properties>
<source.encoding>UTF-8</source.encoding>
<java.version>1.8</java.version>
<spring.boot.version>1.4.2.RELEASE</spring.boot.version>
<primefaces.version>6.0</primefaces.version>
</properties>
<!-- Add typical dependencies for a web application -->
<dependencies>
<!--SPRING BOOT -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.6.1</version>
</dependency>
<dependency>
<groupId>com.rabbitmq</groupId>
<artifactId>amqp-client</artifactId>
<version>5.0.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-bean-validators</artifactId>
<version>2.6.1</version>
</dependency>
<dependency>
<groupId>io.springfox.ui</groupId>
<artifactId>springfox-swagger-ui-rfc6570</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<!--DATABASE -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.1.0.Final</version>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>6.1.0.jre8</version>
</dependency>
<!--COMMONS -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.5</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-hibernate5</artifactId>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>webjars-locator</artifactId>
<version>0.32</version>
</dependency>
<dependency>
<groupId>org.webjars.bower</groupId>
<artifactId>rdash-ui</artifactId>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>org.webjars.bower</groupId>
<artifactId>angular</artifactId>
<version>1.5.9</version>
</dependency>
<dependency>
<groupId>org.webjars.bower</groupId>
<artifactId>angular-cookies</artifactId>
<version>1.5.9</version>
</dependency>
<dependency>
<groupId>org.webjars.bower</groupId>
<artifactId>angular-bootstrap</artifactId>
<version>2.5.0</version>
</dependency>
<dependency>
<groupId>org.webjars.bower</groupId>
<artifactId>angular-ui-router</artifactId>
<version>0.2.18</version>
</dependency>
<dependency>
<groupId>org.webjars.bower</groupId>
<artifactId>angular-ui-mask</artifactId>
<version>1.8.7</version>
</dependency>
<dependency>
<groupId>org.webjars.bower</groupId>
<artifactId>bootstrap</artifactId>
<version>3.3.7</version>
</dependency>
<dependency>
<groupId>org.webjars.bower</groupId>
<artifactId>font-awesome</artifactId>
<version>4.5.0</version>
</dependency>
<dependency>
<groupId>org.webjars.bower</groupId>
<artifactId>angular-resource</artifactId>
<version>1.5.9</version>
</dependency>
<dependency>
<groupId>org.webjars.bower</groupId>
<artifactId>moment</artifactId>
<version>2.17.0</version>
</dependency>
<dependency>
<groupId>org.webjars.bower</groupId>
<artifactId>angular-advanced-searchbox</artifactId>
<version>2.1.0</version>
<exclusions>
<exclusion>
<groupId>org.webjars.bower</groupId>
<artifactId>angular-bootstrap</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.webjars.bower</groupId>
<artifactId>angular-i18n</artifactId>
<version>1.6.3</version>
</dependency>
<dependency>
<groupId>org.webjars.bower</groupId>
<artifactId>ngstorage</artifactId>
<version>0.3.11</version>
</dependency>
<dependency>
<groupId>org.webjars.bower</groupId>
<artifactId>angular-block-ui</artifactId>
<version>0.2.2</version>
</dependency>
<dependency>
<groupId>org.webjars.bower</groupId>
<artifactId>sweetalert</artifactId>
<version>1.1.3</version>
</dependency>
<dependency>
<groupId>org.webjars.bower</groupId>
<artifactId>angular-sweetalert</artifactId>
<version>1.1.0</version>
<exclusions>
<exclusion>
<groupId>org.webjars.bower</groupId>
<artifactId>angular</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.webjars.bower</groupId>
<artifactId>highlightjs</artifactId>
<version>9.9.0</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>angular-highlightjs</artifactId>
<version>0.6.3</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>ngProgress</artifactId>
<version>1.0.6</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<scope>test</scope>
<version>2.44.0</version>
</dependency>
<dependency>
<groupId>com.opera</groupId>
<artifactId>operadriver</artifactId>
<scope>test</scope>
<version>1.5</version>
<exclusions>
<exclusion>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-remote-driver</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<!-- Package as an executable jar -->
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<encoding>${source.encoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<addResources>true</addResources>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>producao</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.4.13</version>
<configuration>
<serverId>docker-hub</serverId>
<imageName>convergencia/integrador-erp</imageName>
<imageTags>
<imageTag>latest</imageTag>
<imageTag>${project.version}</imageTag>
</imageTags>
<pushImageTag>true</pushImageTag>
<baseImage>frolvlad/alpine-oraclejdk8:latest</baseImage>
<volumes>/tmp</volumes>
<workdir>/</workdir>
<env>
<LC_ALL>pt_BR.ISO-8859-1</LC_ALL>
<JAVA_OPTS>
-Duser.language=pt -Duser.country=BR
-Duser.timezone=America/Sao_Paulo
</JAVA_OPTS>
</env>
<runs>
<run>apk add -U tzdata</run>
<run>cp /usr/share/zoneinfo/America/Sao_Paulo /etc/localtime</run>
<run>sh -c 'touch /${project.build.finalName}.jar'</run>
</runs>
<entryPoint>
["sh", "-c", "java $JAVA_OPTS
-Djava.security.egd=file:/dev/./urandom
-jar
/${project.build.finalName}.jar"]
</entryPoint>
<!-- copy the service's jar file from target into the root directory
of the image -->
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.jar</include>
</resource>
</resources>
</configuration>
<executions>
<execution>
<id>build-image</id>
<phase>deploy</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.3</version>
<configuration>
<nodeVersion>v6.9.2</nodeVersion>
<installDirectory>${user.home}</installDirectory>
</configuration>
<executions>
<execution>
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<phase>generate-resources</phase>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<arguments>install</arguments>
</configuration>
</execution>
<execution>
<id>bower install</id>
<goals>
<goal>bower</goal>
</goals>
<configuration>
<arguments>install</arguments>
</configuration>
</execution>
<execution>
<id>gulp build</id>
<goals>
<goal>gulp</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<arguments>build</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>