我用SpringBoot构建了一个简单的应用程序。
测试.java
package Test;
import org.springframework.boot.*;
import org.springframework.boot.autoconfigure.*;
import org.springframework.scheduling.annotation.*;
@SpringBootApplication
@EnableScheduling
public class App
{
public static void main( String[] args )
{
SpringApplication.run (App.class, args);
}
}
pom.xml文件
<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>Test</groupId>
<artifactId>Test</artifactId>
<version>1.0</version>
<name>Test</name>
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.2.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
<version>2.2.0.RELEASE</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.4.0</version>
<configuration>
<fork>true</fork>
<mainClass>${start-class}</mainClass>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
按预期启动。
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.2.0.RELEASE)
2021-01-22 21:10:08.438 INFO 11932 --- [ main] Test.App : Starting App on ASPIRE with PID 11932 (/MvnTest/Test/target/classes started by ch in /data/projects/MvnTest/Test)
2021-01-22 21:10:08.441 INFO 11932 --- [ main] Test.App : No active profile set, falling back to default profiles: default
2021-01-22 21:10:09.421 INFO 11932 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2021-01-22 21:10:09.432 INFO 11932 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2021-01-22 21:10:09.432 INFO 11932 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.27]
2021-01-22 21:10:09.496 INFO 11932 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2021-01-22 21:10:09.496 INFO 11932 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 981 ms
2021-01-22 21:10:09.679 INFO 11932 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2021-01-22 21:10:09.820 INFO 11932 --- [ main] .s.s.UserDetailsServiceAutoConfiguration :
Using generated security password: b1d1aca3-b55e-4d71-aac6-9e33e4d082bd
2021-01-22 21:10:09.889 INFO 11932 --- [ main] o.s.s.web.DefaultSecurityFilterChain : Creating filter chain: any request, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@5a0bef24, org.springframework.security.web.context.SecurityContextPersistenceFilter@1bb740f2, org.springframework.security.web.header.HeaderWriterFilter@29fa6b65, org.springframework.security.web.csrf.CsrfFilter@3ac3f6f, org.springframework.security.web.authentication.logout.LogoutFilter@51b01550, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter@3289079a, org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter@672a1c62, org.springframework.security.web.authentication.ui.DefaultLogoutPageGeneratingFilter@6468a7b6, org.springframework.security.web.authentication.www.BasicAuthenticationFilter@708f018e, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@61f6d381, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@5f95f1e1, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@2f860823, org.springframework.security.web.session.SessionManagementFilter@47406941, org.springframework.security.web.access.ExceptionTranslationFilter@6504a875, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@1d247525]
2021-01-22 21:10:09.903 INFO 11932 --- [ main] o.s.s.c.ThreadPoolTaskScheduler : Initializing ExecutorService 'taskScheduler'
2021-01-22 21:10:09.953 INFO 11932 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2021-01-22 21:10:09.957 INFO 11932 --- [ main] Test.App : Started App in 1.876 seconds (JVM running for 2.209)
我尝试为ldap添加一个依赖项。
<dependency>
<groupId>org.springframework.ldap</groupId>
<artifactId>spring-ldap-core</artifactId>
<version>2.3.3.RELEASE</version>
</dependency>
然后它立即终止。
21:05:32.453 [background-preinit] DEBUG org.jboss.logging - Logging Provider: org.jboss.logging.Log4j2LoggerProvider
21:05:32.456 [background-preinit] INFO org.hibernate.validator.internal.util.Version - HV000001: Hibernate Validator 6.0.17.Final
21:05:32.463 [background-preinit] DEBUG org.hibernate.validator.internal.engine.resolver.TraversableResolvers - Cannot find javax.persistence.Persistence on classpath. Assuming non JPA 2 environment. All properties will per default be traversable.
21:05:32.465 [background-preinit] DEBUG org.hibernate.validator.internal.xml.config.ValidationXmlParser - Trying to load META-INF/validation.xml for XML based Validator configuration.
21:05:32.466 [background-preinit] DEBUG org.hibernate.validator.internal.xml.config.ResourceLoaderHelper - Trying to load META-INF/validation.xml via TCCL
21:05:32.466 [background-preinit] DEBUG org.hibernate.validator.internal.xml.config.ResourceLoaderHelper - Trying to load META-INF/validation.xml via Hibernate Validator's class loader
21:05:32.467 [background-preinit] DEBUG org.hibernate.validator.internal.xml.config.ValidationXmlParser - No META-INF/validation.xml found. Using annotation based configuration only.
21:05:32.551 [background-preinit] DEBUG org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator - Loaded expression factory via original TCCL
21:05:32.555 [background-preinit] DEBUG org.hibernate.validator.internal.engine.ValidatorFactoryImpl - HV000234: Using org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator as ValidatorFactory-scoped message interpolator.
21:05:32.555 [background-preinit] DEBUG org.hibernate.validator.internal.engine.ValidatorFactoryImpl - HV000234: Using org.hibernate.validator.internal.engine.resolver.TraverseAllTraversableResolver as ValidatorFactory-scoped traversable resolver.
21:05:32.555 [background-preinit] DEBUG org.hibernate.validator.internal.engine.ValidatorFactoryImpl - HV000234: Using org.hibernate.validator.internal.util.ExecutableParameterNameProvider as ValidatorFactory-scoped parameter name provider.
21:05:32.555 [background-preinit] DEBUG org.hibernate.validator.internal.engine.ValidatorFactoryImpl - HV000234: Using org.hibernate.validator.internal.engine.DefaultClockProvider as ValidatorFactory-scoped clock provider.
21:05:32.555 [background-preinit] DEBUG org.hibernate.validator.internal.engine.ValidatorFactoryImpl - HV000234: Using org.hibernate.validator.internal.engine.scripting.DefaultScriptEvaluatorFactory as ValidatorFactory-scoped script evaluator factory.
有没有办法让它正常启动?
1条答案
按热度按时间rwqw0loc1#
我怀疑你的版本号有冲突。
在创建springboot项目时,我建议您使用springboot初始值设定项。您可以在这里选择所需的依赖项。然后他们为您生成一个项目,当您查看pom时,您会发现在顶部声明了一个父pom。
通常如下所示,并包含该版本的spring boot的版本:
这个父级是必不可少的,因为spring boot是一个框架,所以框架的每个版本都包含具有特定版本号的依赖项。父pom确保所有依赖项都是共同工作的版本号。您可以在这里了解如何在spring中设置java项目。
这也意味着,当您声明其他spring依赖项时,可以省略版本号,因为父pom将选择一个与该版本spring boot配合良好的版本号。
因此,在声明ldap依赖项时,也可以省略版本号。
但是正如上面提到的,使用初始值设定项创建一个spring引导项目。超级简单。