当前位置: 首页 > 知识库问答 >
问题:

Spring Boot不适用于Liberty Server中的JDBC

韦安顺
2023-03-14

我是Spring Boot的新手。

我正在尝试编写一个 rest api,它应该从数据库中获取数据并将其显示给消费者。我不知道如何处理这个问题。

请帮助在Liberty Server上使用JDBC数据源运行应用程序。简单的Spring启动Rest服务工作正常。

如果有很多问题,请原谅我。我想学这个。

这是我的pom文件:

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

<groupId>com.ankit.demo</groupId>
<artifactId>test-demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>

<name>test-demo</name>
<url>http://maven.apache.org</url>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.1.RELEASE</version>
    <relativePath /> <!-- lookup parent from repository -->
</parent>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
    </dependency>
    <dependency>
        <groupId>com.oracle</groupId>
        <artifactId>ojdbc6</artifactId>
        <version>11.2.0.3</version>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <exclusions>
            <exclusion>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-tomcat</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-actuator</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-jdbc</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <executions>
                <execution>
                    <goals>
                        <goal>repackage</goal>
                    </goals>
                    <configuration>
                        <skip>true</skip>
                    </configuration>
                </execution>
            </executions>
        </plugin>

        <plugin>
            <artifactId>maven-resources-plugin</artifactId>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
    </plugins>
</build>

DemoService.java

package com.ankit.demo;

import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.context.MessageSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

@Configuration
@ComponentScan(basePackages = { "com.ankit.demo.*" })
@SpringBootApplication(exclude = MessageSourceAutoConfiguration.class)
@EnableAutoConfiguration(exclude = { HibernateJpaAutoConfiguration.class,   JpaRepositoriesAutoConfiguration.class })
public class DemoService extends SpringBootServletInitializer {

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder  application) {
        return application.sources(DemoService.class);
    }
}

OracleDatabaseConfiguration.java

package com.ankit.demo.configuration;

import javax.sql.DataSource;

import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.lookup.JndiDataSourceLookup;

@Configuration
public class OracleDatabaseConfiguration {

    @Value("${spring.Oracle.datasource.jndi-name}")
    private String jndiName;

    @Bean(destroyMethod = "")
    public DataSource OracleDataSource() {
        JndiDataSourceLookup dataSourceLookup = new JndiDataSourceLookup();
        return dataSourceLookup.getDataSource(jndiName);
    }

    @Bean()
    @Qualifier("oracleJdbcTemplate")
    public JdbcTemplate jdbcTemplate() {
        return new JdbcTemplate(OracleDataSource());
    }
}

演示控制器.java

package com.ankit.demo.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.ankit.demo.source.IDemoService;
import com.ankit.demo.vo.Employee;

 @RestController
 public class DemoController {

    @Autowired
    private IDemoService iDemoService;

    @RequestMapping(method=RequestMethod.GET, value="/getEmployee")

    public List<Employee> getEmployee() {
        return iDemoService.getEmployee();
    }
}

DemoDAOImpl.java

package com.ankit.demo.respository;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;

import com.ankit.demo.rowmapper.EmployeeMapper;
import com.ankit.demo.source.IDemoDAO;
import com.ankit.demo.vo.Employee;

@Component
public class DemoDAOImpl implements IDemoDAO {

    @Autowired
    @Qualifier("oracleJdbcTemplate")
    private JdbcTemplate jdbcTemplate;

    @SuppressWarnings({ "unchecked", "rawtypes" })
    @Override
    public List<Employee> getEmployee() {
        String sql = "SELECT * FROM EMPLOYEE";
        List<Employee> empLst = null;
        try {
            empLst = jdbcTemplate.query(sql, new EmployeeMapper());
        }catch(Exception ex) {

        }
        return empLst;
    }

}

EmployeeMapper.java

package com.ankit.demo.rowmapper;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.jdbc.core.RowMapper;

import com.ankit.demo.vo.Employee;

public class EmployeeMapper<T> implements RowMapper<Employee>{

    @Override
    public Employee mapRow(ResultSet rs, int rowNum) throws SQLException   {

        Employee emp = new Employee();
        try {
            if(rs != null) {
                if(rs.next()) {
                   emp.setEmpId(rs.getLong("EMP_ID"));
                   emp.setEmpName(rs.getString("EMP_NAME"));
                   emp.setAccName(rs.getNString("ACCOUNT_NAME"));
                   emp.setJoinDate(rs.getDate("JOINING_DATE"));
                }
            }else {
                System.out.println("Result Set is null");
            }
        }catch(Exception ex) {
            ex.printStackTrace();
        }finally {
            if(rs != null) {
                rs.close();
            }
        }
        return emp;
    }

}

演示服务Impl.java

package com.ankit.demo.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.ankit.demo.source.IDemoDAO;
import com.ankit.demo.source.IDemoService;
import com.ankit.demo.vo.Employee;

public class DemoServiceImpl implements IDemoService {

    @Autowired
    private IDemoDAO iDemoDAO;

    @Override
    public List<Employee> getEmployee() {
        return iDemoDAO.getEmployee();
    }

}

员工.java

package com.ankit.demo.vo;

import java.util.Date;

public class Employee {

    private long empId;
    private String empName;
    private String accName;
    private Date joinDate;

    public long getEmpId() {
        return empId;
    }
    public void setEmpId(long empId) {
        this.empId = empId;
    }
    public String getEmpName() {
        return empName;
    }
    public void setEmpName(String empName) {
        this.empName = empName;
    }
    public String getAccName() {
        return accName;
    }
    public void setAccName(String accName) {
        this.accName = accName;
    }
    public Date getJoinDate() {
        return joinDate;
    }
    public void setJoinDate(Date joinDate) {
        this.joinDate = joinDate;
    }

    @Override
    public String toString() {
        return "Employee [empId=" + empId + ", empName=" + empName + ",  accName=" + accName + ", joinDate=" + joinDate
            + "]";
    }
}

server.xml

<server description="new server">

<!-- Enable features -->
<featureManager>
    <feature>webProfile-7.0</feature>
    <feature>localConnector-1.0</feature>
    <feature>jaxb-2.2</feature>
</featureManager>

<!-- To access this server from a remote client add a host attribute to 
    the following element, e.g. host="*" -->
<httpEndpoint httpPort="9080" httpsPort="9443"
    id="defaultHttpEndpoint" />

<!-- Automatically expand WAR files and EAR files -->
<applicationManager autoExpand="true" />
<applicationMonitor updateTrigger="mbean" />

<!-- WEB APPLICATION -->
<webApplication id="test-demo" location="test-demo.war" name="test-demo" />

<!-- ORACLE DATASOURCE -->
<dataSource id="DefaultDataSource" jndiName="jdbc/oracle" connectionSharing="MatchOriginalRequest" isolationLevel="TRANSACTION_READ_UNCOMMITTED" statementCacheSize="20">
    <connectionManager maxPoolSize="20" minPoolSize="5" connectionTimeout="30s" agedTimeout="30m"></connectionManager>
    <jdbcDriver libraryRef="OracleLib" />
    <properties.oracle URL="jdbc:oracle:thin:@//localhost:1521/xe" user="system" password="{xor}PjsyNjE=" />
</dataSource>

<!-- ORACLE JDBC DRIVER LIBRARY -->
<library id="OracleLib">
    <file name="E:/LocalRepository/.m2/repository/com/oracle/ojdbc6/11.2.0.3/ojdbc6.jar" />
</library>
</server>

输出控制台

[AUDIT   ] CWWKT0016I: Web application available (default_host):  http://localhost:9080/test-demo/
[AUDIT   ] CWWKZ0003I: The application test-demo updated in 8.963 seconds.
[WARNING ] CWNEN0047W: Resource annotations on the fields of the org.springframework.web.servlet.view.tiles3.TilesConfigurer$CompositeELResolverImpl class will be ignored. The annotations could not be obtained because of the exception : java.lang.NoClassDefFoundError: org/apache/tiles/el/ScopeELResolver
[WARNING ] CWNEN0049W: Resource annotations on the methods of the org.springframework.web.servlet.view.tiles3.TilesConfigurer$CompositeELResolverImpl class will be ignored. The annotations could not be obtained because of the exception : java.lang.NoClassDefFoundError: org/apache/tiles/el/ScopeELResolver
[WARNING ] SRVE0190E: File not found: /getEmployee

我将我的springbootstarter父版本更改为1.3.3,并得到以下异常

java.lang.IllegalStateException: Could not evaluate condition on org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration#propertySourcesPlaceholderConfigurer due to org/springframework/jdbc/core/JdbcTemplate not found. Make sure your own configuration does not rely on that class. This can also happen if you are @ComponentScanning a springframework package (e.g. if you put a @ComponentScan in the default package by mistake)
at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:55) ~[spring-boot-autoconfigure-1.3.3.RELEASE.jar:1.3.3.RELEASE]
at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:102) ~[spring-context-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForBeanMethod(ConfigurationClassBeanDefinitionReader.java:178) ~[spring-context-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:140) ~[spring-context-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:116) ~[spring-context-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:333) ~[spring-context-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:243) ~[spring-context-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:273) ~[spring-context-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:98) ~[spring-context-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:678) ~[spring-context-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:520) ~[spring-context-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) ~[spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:766) ~[spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]
at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:361) ~[spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) ~[spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]
at org.springframework.boot.context.web.SpringBootServletInitializer.run(SpringBootServletInitializer.java:149) [spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]
at org.springframework.boot.context.web.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:129) [spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]
at org.springframework.boot.context.web.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:85) [spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]
at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:175) [spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at com.ibm.ws.webcontainer.webapp.WebApp.initializeServletContainerInitializers(WebApp.java:2490) [com.ibm.ws.webcontainer_1.1.18.jar:na]
at com.ibm.ws.webcontainer.webapp.WebApp.initialize(WebApp.java:1002) [com.ibm.ws.webcontainer_1.1.18.jar:na]
at com.ibm.ws.webcontainer.webapp.WebApp.initialize(WebApp.java:6550) [com.ibm.ws.webcontainer_1.1.18.jar:na]
at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost.startWebApp(DynamicVirtualHost.java:469) [com.ibm.ws.webcontainer_1.1.18.jar:na]
at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost.startWebApplication(DynamicVirtualHost.java:464) [com.ibm.ws.webcontainer_1.1.18.jar:na]
at com.ibm.ws.webcontainer.osgi.WebContainer.startWebApplication(WebContainer.java:1119) [com.ibm.ws.webcontainer_1.1.18.jar:na]
at com.ibm.ws.webcontainer.osgi.WebContainer.access$000(WebContainer.java:103) [com.ibm.ws.webcontainer_1.1.18.jar:na]
at com.ibm.ws.webcontainer.osgi.WebContainer$2.run(WebContainer.java:931) [com.ibm.ws.webcontainer_1.1.18.jar:na]
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [na:1.8.0_151]
at java.util.concurrent.FutureTask.run(Unknown Source) [na:1.8.0_151]
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [na:1.8.0_151]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)  [na:1.8.0_151]
at java.lang.Thread.run(Unknown Source) [na:1.8.0_151]
Caused by: java.lang.NoClassDefFoundError: org/springframework/jdbc/core/JdbcTemplate
at java.lang.Class.getDeclaredMethods0(Native Method) ~[na:1.8.0_151]
at java.lang.Class.privateGetDeclaredMethods(Unknown Source) ~[na:1.8.0_151]
at java.lang.Class.getDeclaredMethods(Unknown Source) ~[na:1.8.0_151]
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:609) ~[spring-core-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:521) ~[spring-core-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:507) ~[spring-core-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.util.ReflectionUtils.getUniqueDeclaredMethods(ReflectionUtils.java:567) ~[spring-core-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryMethod(AbstractAutowireCapableBeanFactory.java:683) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:627) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:597) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1445) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:975) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.boot.autoconfigure.condition.BeanTypeRegistry$OptimizedBeanTypeRegistry.addBeanTypeForNonAliasDefinition(BeanTypeRegistry.java:289) ~[spring-boot-autoconfigure-1.3.3.RELEASE.jar:1.3.3.RELEASE]
at org.springframework.boot.autoconfigure.condition.BeanTypeRegistry$OptimizedBeanTypeRegistry.addBeanType(BeanTypeRegistry.java:278) ~[spring-boot-autoconfigure-1.3.3.RELEASE.jar:1.3.3.RELEASE]
at org.springframework.boot.autoconfigure.condition.BeanTypeRegistry$OptimizedBeanTypeRegistry.getNamesForType(BeanTypeRegistry.java:259) ~[spring-boot-autoconfigure-1.3.3.RELEASE.jar:1.3.3.RELEASE]
at org.springframework.boot.autoconfigure.condition.OnBeanCondition.collectBeanNamesForType(OnBeanCondition.java:182) ~[spring-boot-autoconfigure-1.3.3.RELEASE.jar:1.3.3.RELEASE]
at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getBeanNamesForType(OnBeanCondition.java:171) ~[spring-boot-autoconfigure-1.3.3.RELEASE.jar:1.3.3.RELEASE]
at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchingBeans(OnBeanCondition.java:139) ~[spring-boot-autoconfigure-1.3.3.RELEASE.jar:1.3.3.RELEASE]
at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchOutcome(OnBeanCondition.java:113) ~[spring-boot-autoconfigure-1.3.3.RELEASE.jar:1.3.3.RELEASE]
at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:47) ~[spring-boot-autoconfigure-1.3.3.RELEASE.jar:1.3.3.RELEASE]
... 31 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.springframework.jdbc.core.JdbcTemplate
at com.ibm.ws.classloading.internal.AppClassLoader.findClassCommonLibraryClassLoaders(AppClassLoader.java:504) ~[na:na]
at com.ibm.ws.classloading.internal.AppClassLoader.findClass(AppClassLoader.java:276) ~[na:na]
at java.lang.ClassLoader.loadClass(Unknown Source) ~[na:1.8.0_151]
at com.ibm.ws.classloading.internal.AppClassLoader.findOrDelegateLoadClass(AppClassLoader.java:482) ~[na:na]
at com.ibm.ws.classloading.internal.AppClassLoader.loadClass(AppClassLoader.java:443) ~[na:na]
at java.lang.ClassLoader.loadClass(Unknown Source) ~[na:1.8.0_151]
... 51 common frames omitted

2018-04-17 23:55:39.228  INFO 5692 --- [utor-thread-104] .b.l.ClasspathLoggingApplicationListener : Application failed to start with classpath: unknown

共有2个答案

司徒捷
2023-03-14

将以下行添加到“application.properties”文件中:

spring.h2.console.enabled=true
慕永年
2023-03-14

我已经解决了我所面临的问题。请找到下面我做的步骤。

  1. 添加了所有与Spring相关的(Spring芯,Spring豆,SpringJDBC等)罐子到WEB-INF/库文件夹。
  2. 在我错过的地方添加了@Component注释,因为应用程序给出了@Autowired未定义的bean。
  3. 从服务器.xml中删除了“隔离级别=”TRANSACTION_READ_UNCOMMITTED“。这是较早设置的,因此我得到“无法获得JDBC连接异常”。
  4. 在服务器中添加了“jndi-1.0”、“jdbc-4.1”、“jpa-2.1”功能.xml

我不知道这是解决问题的办法还是确切的解决方案,但它确实对我有效。

请纠正我,以防这只是一个解决方法。

 类似资料:
  • 我有一个springboot应用程序,当我在intellij内部运行时,它不与JSP一起工作,但当生成一个JAR时,它就不工作了。它给出了这个错误。 Whitelabel错误页面此应用程序没有 /error的显式映射,因此您将其视为后备方案。 IST 2018年5月21 00:23:11星期一出现意外错误(类型=未找到,状态=404)。没有可用的消息 JSP文件存在于src/main/resour

  • 我正在springboot应用程序中编写Junits,它只有一个初始化器类 以及其他控制器和服务类。 服务类的Junit如下所示: 当我运行Junit时,它会抛出如下错误: 我还尝试了所有注释,如,@ContextConfiguration(classes=Initializer.class),,但它仍会抛出相同的错误。代码中没有其他类似于应用程序上下文的配置类。

  • 当我试图通过邮递员发送时,我有一个请求正在正常工作。我试图实现相同的使用代码,我面临一个错误。 我正在使用的代码- 我得到的错误是- org.springframework.web.client.HttpClientErr异常$未授权: 401未授权 但《邮递员》中同样的作品也有同样的细节。 我想说明一下 后端API不在我手里。 clientid,clientSecret,access_token

  • 我的GMAILIMAP代码在PHP从我的localhost工作得很好,但它不能从域工作。 我已完成以下项目: 1) 允许不太安全的应用登录2)在GMAIL帐户中启用IMAP 3)未启用双因素身份验证。4) 我也验证了帐户访问权限5)我还允许:http://www.google.com/accounts/DisplayUnlockCaptcha 可能是我在实时服务器上没有SSL的问题吗? 但我不断得

  • 问题内容: 嗨,我只是简单地尝试在www.example.com上获取h1标签,该标签显示为“ Example Domain”。该代码适用于http://www.example.com,但不适用于https://www.exmaple.com。我该如何解决这个问题?谢谢 问题答案: PhantomJSDriver不支持(所有)DesiredCapabilities。 你会需要: 记录在这里:htt

  • 所以我使用这种方法写入文件,它在windows上运行完全正常,但在mac上运行时,它会创建文件,但它们是空的。 我知道数据是正确的,因为它打印正确。感谢您的任何帮助,这真的让我绊倒了。