我在运行通过“mvn 包”创建的 jar 时遇到问题。我尝试了各种解决方案,但没有成功。
pom.xml
<groupId>org.springframework</groupId>
<artifactId>rest-service</artifactId>
<version>0.1.0</version>
<packaging>jar</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.4.RELEASE</version>
</parent>
...
<properties>
<java.version>1.8</java.version>
<start-class>ves.sfdc.Application</start-class>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud)
projectroot\src\main\java\ves\sfdc\application.java
@SpringBootApplication
@Configuration
@ComponentScan
@EnableAsync
@EnableScheduling
@EnableAutoConfiguration
public class Application{
@Autowired
JdbcTemplate jdbcTemplate;
@Autowired
AccountService accountService;
@Autowired
static
SfdcUtil sfdcUtil= new SfdcUtil();
@Autowired
NamedParameterJdbcTemplate jdbcTemplate2;
public static void main(String[] args) throws SecurityException, IOException {
SpringApplication.run(Application.class, args);
}
} …Run Code Online (Sandbox Code Playgroud)